One more thought:
Is there a sane way to hide a schema object within another schema object?
Specifically, I want to make a factory method (or maybe a class decorator)
which generates these Tag schemas onto specific tables. Something along the
lines of:
@Taggable
class User(BaseModel)
__tablename__ = "user"
The Taggable class decorator would generate another table called "tag_user"
and attach the appropriate relationship attributes to the User class. I'm
thinking it'll also attach the anonymous Tag declarative class to the User
class as User.TagClass or somesuch.
Is this reasonable? Is there a better way to do this than monkey-patching
the User class in the Taggable decorator?
One fantasy I had was if you could do...
class TaggableMixin(object):
@declared_attr
def TaggableClass(cls):
class Tag(BaseModel):
__tablename__ = "tag_%s" % cls.__tablename__
# ... schema here
class User(BaseModel, TaggableMixin):
# ...
Perhaps I should try it but I don't imagine this will work.
- Andrey
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en.