Hi,
I am just starting to use the relation between two tables.
The problem started with the child data not being written to the child
tables.
I played around, and now I am totally confused.
Maybe someone can shed some light on this.
I got these tables:
{{{
user_table = sa.Table('User', meta.metadata,
sa.Column('UserId', sa.types.Integer(),
primary_key=True),
sa.Column('UserDesc', sa.types.UnicodeText(),
default=u''),
)
userrealm_table = sa.Table('UserRealm', meta.metadata,
sa.Column('id', sa.types.Integer(), primary_key=True),
sa.Column('user_id',
sa.types.Integer(),ForeignKey('User.UserId')),
sa.Column('realm_id', sa.types.Integer(),
nullable=False )
)
}}}
I got the following classes:
{{{
class User(object):
def __init__(self, desc):
log.debug(' __init__(%s)' % desc)
self.UserDesc = serial
classe UserRealm(object):
def __init__(self, realm):
log.debug("setting realm_id to %i" % realm)
self.realm_id = realm
}}}
A user may belong to several realms. All the relation stuff should be
done in the mappers:
{{{
orm.mapper(UserRealm, userrealm_table)
orm.mapper(User, user_table, properties={
'children':relationship(UserRealm,backref='user', cascade="save-
update")
})
}}}
Now I am at the point, that the User object contains no attribute
identifying the realm...
I thought this attribute should be generated by the relation
definition?
Any ideas on this?
Kind regards
Cornelius
--
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.