On 3/19/07, George Sakkis <[EMAIL PROTECTED]> wrote:
>
> > > I'm starting again with TurboGears after a failed attempt a year ago
> > > or so; things look more polished now. I quickstarted a project with
> > > SQLalchemy and Identity enabled and I'm looking at the generated
> > > models.py. There are two tables there, visits_table and
> > > visits_identity_table (and the associated mapped classes). My question
> > > is, why aren't these merged in one table, that is:
> >
> > this is because they represent two diff things, a visit is anyone
> > inside your app, it can be an autenticated user or not and it also
> > stores visit's that have already expired. While a visit identity is a
> > Visit that is authenticated and therefore related to a User object.
> >
> > > visits_table = Table('visit', metadata,
> > > Column('visit_key', String(40), primary_key=True),
> > > Column('created', DateTime, nullable=False, default=datetime.now),
> > > Column('expiry', DateTime),
> > > Column('user_id', Integer, ForeignKey('tg_user.user_id'),
> > > index=True)
> > > )
> >
> > this way the only reason to check your anon users will be to see if
> > that FK points to a user or not, very hackish IMO :)
>
> For anon users the FK would be NULL; what's hackish about "select *
> from visits_table where user_id is NULL" ? :)
>
first of all that null could be an error and not exactly an annon
user, second if you read the identity code it's based on the fact that
no identity = anon User, it's very clever since you don't have to be
checking for null all the time. last but not least Visit and Identity
are two different modules so each table belongs to each module
> > > Also in the mapping later there is:
> >
> > > assign_mapper(session.context, VisitIdentity, visit_identity_table,
> > > properties=dict(users=relation(User,
> > > backref='visit_identity')))
> >
> > > Doesn't a visit identity refer to a single user ? What does the
> > > "users" property refer to ? I'm probably missing something obvious
> > > here but I didn't find anything relevant in the docs.
> >
> > think having two computers, you have 1 user two sessions.
>
> Isn't the mapper assignment saying the inverse, one session many
> users ?
yes your right, I'm not very familiar with SA.
>
I just took a closer look and there seems to be an inconcistency
between the SO/SA models
the tables seems correct
http://trac.turbogears.org/browser/trunk/turbogears/qstemplates/quickstart/%2Bpackage%2B/model.py_tmpl#L49
http://trac.turbogears.org/browser/trunk/turbogears/qstemplates/quickstart/%2Bpackage%2B/model.py_tmpl#L143
but the relationships for SA seems different
http://trac.turbogears.org/browser/trunk/turbogears/qstemplates/quickstart/%2Bpackage%2B/model.py_tmpl#L237
Could someone with more SA experience take a look?
> George
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---