> @classmethod > def forEncode(self): Because of @classmethod, self isn't an instance, it's the class (probably either exModel or exStateModel). While the ReferenceProperty object itself is part of the class, the actual values are associated with instances.
On Apr 1, 9:06 am, Rein Petersen <[email protected]> wrote: > Maybe a bit of pared down code will help get a response for this > problem: > > from google.appengine.ext import db > > class exModel(db.Model): > state = db.ReferenceProperty() > name = db.StringProperty() > @classmethod > def forEncode(self): > baseDct = {"name":self.name} > if self.state: baseDct["state"] = self.state.forEncode() > return baseDct > > class exStateModel(db.Model): > desc = db.StringProperty() > @classmethod > def forEncode(self): > return {"desc":self.description } > > The line [ baseDct["state"]:self.state.forEncode() ] found in the > forEncode method of exModel coughs up this: > > AttributeError: 'ReferenceProperty' object has no attribute > 'forEncode' > > i get a similar error asking for any attribute. i just can't get at > the instance or anything about like the documentation demonstrates. > And i know its there, i confirmed it using the data viewer and the > reference and referenced instance are there... help me before i blow a > gasket... > > Thanks, Rein > > On Mar 31, 11:29 pm, Rein Petersen <[email protected]> wrote: > > > > > Hi, > > > i have a model with a referenceproperty that points to another > > instance of a model. i know the entity is stored because i can see the > > reference property and the referenced entity in the dataviewer. > > > But, when i try to access the referenced instance or anything about > > the referenced instance (as i understand from the online docs), i just > > get the following error: > > > AttributeError: 'ReferenceProperty' object has no attribute ... > > > How can i instance a model entity with a ReferenceProperty object? > > This should be trivial i think but the docs say that just by accessing > > an attribute should trigger the fetch. i dont see that happening when > > i execute : > > > modelAinstance.modelBref.myattribute > > > where modelAinstance is an instance of ModelA which contains the > > attribute ModelBref which is a ReferenceProperty holding a reference > > to an instance of ModelB > > > What am i missing? > > > Thanks for the help... > > > Rein- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
