本文整理汇总了Python中pycassa.columnfamily.ColumnFamily.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python ColumnFamily.__init__方法的具体用法?Python ColumnFamily.__init__怎么用?Python ColumnFamily.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycassa.columnfamily.ColumnFamily
的用法示例。
在下文中一共展示了ColumnFamily.__init__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import __init__ [as 别名]
def __init__(self, cls, pool, column_family, columns=None, raw_columns=False, **kwargs):
"""
Maps an existing class to a column family. Class fields become columns,
and instances of that class can be represented as rows in standard column
families or super columns in super column families.
Instances of `cls` are returned from :meth:`get()`, :meth:`multiget()`,
:meth:`get_range()` and :meth:`get_indexed_slices()`.
`pool` is a :class:`~pycassa.pool.ConnectionPool` that will be used
in the same way a :class:ColumnFamily uses one.
`column_family` is the name of a column family to tie to `cls`.
If `raw_columns` is ``True``, all columns will be fetched into the
`raw_columns` field in requests.
"""
ColumnFamily.__init__(self, pool, column_family, **kwargs)
self.cls = cls
self.autopack_names = False
self.raw_columns = raw_columns
self.dict_class = util.OrderedDict
self.defaults = {}
self.fields = []
for name, val_type in self.cls.__dict__.iteritems():
if isinstance(val_type, CassandraType):
self.fields.append(name)
self.column_validators[name] = val_type
self.defaults[name] = val_type.default
示例2: __init__
# 需要导入模块: from pycassa.columnfamily import ColumnFamily [as 别名]
# 或者: from pycassa.columnfamily.ColumnFamily import __init__ [as 别名]
def __init__(self, cls, pool, column_family, raw_columns=False, **kwargs):
"""
Instances of `cls` are returned from :meth:`get()`, :meth:`multiget()`,
:meth:`get_range()` and :meth:`get_indexed_slices()`.
`pool` is a :class:`~pycassa.pool.ConnectionPool` that will be used
in the same way a :class:`~.ColumnFamily` uses one.
`column_family` is the name of a column family to tie to `cls`.
If `raw_columns` is ``True``, all columns will be fetched into the
`raw_columns` field in requests.
"""
ColumnFamily.__init__(self, pool, column_family, **kwargs)
self.cls = cls
self.autopack_names = False
self.raw_columns = raw_columns
self.dict_class = util.OrderedDict
self.defaults = {}
self.fields = []
for name, val_type in inspect.getmembers(self.cls):
if name != 'key' and isinstance(val_type, CassandraType):
self.fields.append(name)
self.column_validators[name] = val_type
self.defaults[name] = val_type.default
if hasattr(self.cls, 'key') and isinstance(self.cls.key, CassandraType):
self.key_validation_class = self.cls.key