Datastore Property

2 views
Skip to first unread message

leone

unread,
May 13, 2008, 6:38:06 AM5/13/08
to Google App Engine
How can I know the property types of a model using model.properties?
Thanks

Brett Morgan

unread,
May 13, 2008, 7:17:32 AM5/13/08
to google-a...@googlegroups.com
I'm curious. Why do you need to know?

On Tue, May 13, 2008 at 8:38 PM, leone <hand...@gmail.com> wrote:
>
> How can I know the property types of a model using model.properties?
> Thanks
> >
>

--

Brett Morgan http://brett.morgan.googlepages.com/

leone

unread,
May 13, 2008, 8:00:16 AM5/13/08
to Google App Engine
I am using a model without knowledge about its properties and I need
to extract from model.

On 13 Mag, 13:17, "Brett Morgan" <brett.mor...@gmail.com> wrote:
> I'm curious. Why do you need to know?
>

Brett Morgan

unread,
May 13, 2008, 8:02:26 AM5/13/08
to google-a...@googlegroups.com
I'm having mental images of DataStore entities going to Yoga class to
attain self awareness.

--

Brett Morgan http://brett.morgan.googlepages.com/

leone

unread,
May 13, 2008, 8:09:19 AM5/13/08
to Google App Engine
...know yourself, said socrates.
Model object contains information about its structure? How can I
access to?

joh...@easypublisher.com

unread,
May 13, 2008, 1:09:44 PM5/13/08
to google-a...@googlegroups.com
Hi leone,
Model.properties() returns a dict, the key is you property name and
value is the property type object.
/Johan

PS.
I've made this self-reflection method on my model class (all it with
self.response.out.write as an argument from your handler):


class Base(db.Model):
name = db.StringProperty()

def write_me(self, write):

write('<h1>Writing: %s<h1>' %(escape(str(self)),))
write('<h2>self.__dict__</h2>')
for key, value in self.__dict__.items():
write('<p><strong>key:</strong>
%20s<br/><strong>value:</strong> %20s</p>' % (key, escape(str(value)))
)
write('<p></p>')
write('<h2>self.properties()</h2>')
for key, value in self.properties().items():
write('<p><strong>key:</strong>
%20s<br/><strong>value:</strong> %20s</p>' % (key, escape(str(value)))
)

class MainHandler(webapp.RequestHandler):
def get(self):
...
obj.write_me(self.response.out.write)
...


--
Johan Carlsson
Colliberty Easy Publisher
http://www.easypublisher.com

leone

unread,
May 14, 2008, 4:06:05 AM5/14/08
to Google App Engine
Thank you. Do you know where I can find info about classes used by GAE
environment?
Reply all
Reply to author
Forward
0 new messages