Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Look at object parents when mapping to column families #181

Merged
merged 1 commit into from over 1 year ago

2 participants

Jeremy Katz Tyler Hobbs
Jeremy Katz

Using self.cls.dict only looks at the members of the class and not any parents. Better to use inspect.getmembers() for this purpose and get the full hierarchy

Jeremy Katz katzj Look at object parents when mapping to column families
Using self.cls.__dict__ only looks at the members of the class and
not any parents.  Better to use inspect.getmembers() for this
purpose and get the full hierarchy
335995e
Tyler Hobbs thobbs merged commit 74a5a32 into from
Tyler Hobbs
Owner

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 05, 2012
Jeremy Katz katzj Look at object parents when mapping to column families
Using self.cls.__dict__ only looks at the members of the class and
not any parents.  Better to use inspect.getmembers() for this
purpose and get the full hierarchy
335995e
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. +2 1  pycassa/columnfamilymap.py
3  pycassa/columnfamilymap.py
@@ -14,6 +14,7 @@
14 14 from pycassa.types import CassandraType
15 15 from pycassa.columnfamily import ColumnFamily
16 16 import pycassa.util as util
  17 +import inspect
17 18
18 19 __all__ = ['ColumnFamilyMap']
19 20
@@ -51,7 +52,7 @@ def __init__(self, cls, pool, column_family, raw_columns=False, **kwargs):
51 52 self.dict_class = util.OrderedDict
52 53 self.defaults = {}
53 54 self.fields = []
54   - for name, val_type in self.cls.__dict__.iteritems():
  55 + for name, val_type in inspect.getmembers(self.cls):
55 56 if name != 'key' and isinstance(val_type, CassandraType):
56 57 self.fields.append(name)
57 58 self.column_validators[name] = val_type

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.