python - Getting implicit property names on a db.Model in Google App Engine? -
how can access implicit property names of db.model in google app engine? in particular, assume have following:
class foo(db.model): specific = db.integerproperty() class bar(db.model): foo = db.referenceproperty(foo, collection_name = "bars")
if attempt property names on foo, so:
my_foo = foo(specific = 42) key, prop in my_foo.properties().iteritems() print "here bars won't show up"
then my_foo.bars property doesn't show up. or totally mistaken?
any appreciated
edited model python, not ruby
(that model definition looks strange hybrid of python , ruby.)
i'm not clear on you're trying achieve here, can list of model property members using introspection:
[x x in dir(foo) if isinstance(getattr(foo,x), db.property)]
if you're trying add instances of bar foo, should create new bar instances foo fields pointing @ foo instance:
foo = foo(specific=42) foo.put() bar(foo=foo).put() bar(foo=foo).put() logging.info("foo bars: %r" % list(foo.bars))
Comments
Post a Comment