I haven't tried that Robin.  It looks promising.  I'll give it a try.
Thanks.

On Nov 19, 10:18 am, Robin B <[EMAIL PROTECTED]> wrote:
> Have you tried having ModelMixin inherit from PropertiedClass
> directly:
>
> class ModelMixin(PropertiedClass):
>   pass
>
> class Commentable():
>   __metaclass__ = ModelMixin
>
> I am using something similar without error.
>
> Robin
>
> On Nov 19, 8:07 am, Adam <[EMAIL PROTECTED]> wrote:
>
> > Not that anyone cares, but the metaclass approach did not work, as
> > Python doesn't want to have two non-identical metaclasses in an
> > inheritance chain.  Or something.
>
> > On Nov 18, 10:42 am, Adam <[EMAIL PROTECTED]> wrote:
>
> > > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to