Hello all,
I have the following scenario:
I have 5 or 6 related sqlalchemy declarative models sitting in a pyramid
app. This occurs in the context of extending a pyramid application, where I
import/config.scan() these selected models from another pyramid app into a
new app. The thing is that these models have the original app's declarative
base and I need them to work with the new app's declarative base.
So I tried to change their declarative base upon importing. (also with
giving a new name to avoid possible name collisions)
This was my approach:
newmodel = type(newmodelname, (newdeclarativebase, oldmodel), {})
which worked out pretty well!!! except for one nuisance, which is that
already instrumented relationships are still bound to the old models
instead of the new ones.
class OldParentModel(oldbase):
rel = relationship("OldChildModel")
>> new = query(NewParentModel).first()
>> new.rel
[<oldapp.models.OldChildModel at 0xb1cbfac>]
I wished that they are linked to NewChildModel instead.
so is there a way to avoid this problem or at least remap the already
mapped relationships to the new models?
Or perhaps a whole different approach to dealing with this (without
actually redefining the whole classes again in the new app)?
Cheers,
Ahmed
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.