It just occurred to me that this solution could be made much easier by
using a simple, small metaclass (which, it is worth noting, I totally
copped from GAE's PropertiedClass metaclass):
class ModelMixin(type):
def __init__(cls, name, bases, dct):
super(PropertiedClass, cls).__init__(name, bases, dct)
for attr_name in dct.keys():
attr = dct[attr_name]
if isinstance(attr, Property):
cls._properties[attr_name] = attr
class Commentable():
__metaclass__ = ModelMixin
comments_counter = db.IntegerProperty(required=True, default=0)
Bada-bing. Now, the ugly nonsense of creating the _properties dict
and assigning to it is gone.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---