Hello everybody,

Happy New Year!

I'm using GAE and sometimes a need to call some GAE datastore functions 
directly.

(For instance when I want to supply a "key_name" when I put() an entity so 
I can have better performance to get() that entity from db.
Or when I want to use put_multi())

Anyway, I can use the "*_tableobj*" property of the web2py table to access 
the GAE model class.

But, this class does not have the defaults applied to it's properties while 
the Fields on the web2py table do.
This means that when I put() my _tableobj instance (using GAE API) , the 
defaults are not set in the database record.

At the moment a call this function in my db model after each table 
definition:


@classmethod
    def set_defaults(cls, table):
        """
        Takes a web2py table and sets the defaults of all Fields and sets
        those defaults on the associated properties of the tableobj
        (tableobj = the GAE model class associated with the web2py table)
        """
        for propname, prop in table._tableobj._properties.iteritems():
            field = getattr(table, propname, None)
            if None != field and isinstance(field, Field):
                prop._default = field.default

Can this (or something like this) be integrated in the create_table() 
method of GoogleDatastoreAdapter() so it's done when the table gets created?

Thanks,

Regards

Quint

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to