On Dec 17, 2008, at 2:28 AM, Joril wrote:

>
> Michael Bayer ha scritto:
>
>> "concrete inheritance", as referenced in that post, was not designed
>> to be used as a configurational spacesaver and always requires a
>> mapped selectable for the "base", which you don't have here, so it's
>> not appropriate for this use case.
>>
>>
>> So for this you'd need a custom metaclass:
>
> I see, thanks! Now my problem is that I already have a custom
> metaclass, defining a set of common attributes for ALL my classes..
> So, to declare additional fields for just a few classes, would it be
> ok to subclass the custom metaclass again and re-call declarative_base
> ()?
>
> To clarify:
> All classes have a "timestamp" attribute, and a few of them has a
> "notes" attribute too.
>
> Thanks again!

yes that is entirely OK.   A second "declarative_base" may share the  
metadata of the first, Base =  
declarative_base(metadata=somemetadata).   If you want to use strings  
for relation() classes across the two bases, the _decl_class_registry  
would need to be shared as well:

meta = MetaData()
Base1 = declarative_base(metadata=meta, metaclass=MyMetaClass)
Base2 = declarative_base(metadata=meta, metaclass=MyOtherMetaClass)
Base2._decl_class_registry = Base1._decl_class_registry

This is a use case we can make easier in a future release.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to