On Aug 15, 2011, at 12:46 AM, cd34 wrote:

> On Aug 14, 11:39 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
>>> receive the ExtendedProfile class declarations.
>> 
>> Well those are two different classes, so first you'd need to assign a 
>> relationship() to AuthUser that references ExtendedProfile.  If you're 
>> looking for "backref" to do this via ExtendedProfile that's:
>> 
>> class ExtendedProfile(...):
>>     user = relationship("AuthUser", backref="profile")
>> 
>> this assigns a relationship() to ExtendedProfile and AuthUser.
> 
> I am able to do that. What I'm trying to do is have a base class that
> is declared in a package that is installed through easy_install (for
> Pyramid), then, allow the user to extend the class locally. So, the
> person installs my package, but, needs to be able to extend
> user_profile themselves.
> 
> https://github.com/cd34/pyramid_apex/blob/master/pyramid_apex/views.py
> 
> The issue I'm running into currently is that in the model definition
> in pyramid, I don't have access to the config registry to override the
> class creation. So, I'm looking for a way to either do a late binding
> on the relation, or, need to do some really creative coding so that my
> module can access a user supplied profile class.

A relationship() can be added at any time to any mapped class - when using 
declarative config, just assigning it to the class is all that's needed, 
mapper.add_property() is called as a result.     Using "backref" where you had 
"back_populates" should also achieve the result of adding a relationship().

Otherwise if "extend" means "subclass", that's an option as well (though it 
means you can't change your base class without risking backwards 
incompatibility).



-- 
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