Hello,

I'm implementing an authentication system in my webapp, with the usual users / roles.

I have a table "human", a table "role" and a table "human_role". I have one special user "anonymous" which has no password, no email, etc and two special roles : "anonymous user" and "authenticated user".

If an user is authenticated it has automatically the role "authenticated user" in it's roles. On the other way, if the user is just visiting the website without authenticating it should be an "anonymous" user and this user should automatically get the "anonymous user" in it's roles.

Those two roles and the "anonymous" user should always exist. To avoid unnecessary SQL queries, and to simplify the implementation I would like to avoid storing those roles and the anonymous user in the database.

I wondered if there is a way to treat those two roles the same way as the other ones except in all the orm/save/update/cascade/... operations .. ?

For example I have an user "foo", which has roles: "reviewer" and "reader". I would like to do something like:

foo_user = User.query.filter_by(login='foo').one()
then a property like foo_user.roles which should return ['authenticated', 'reviewer', 'reader'], so 'authenticated' should be automatically added (but, again, ignored in all the orm/save/update/cascade/... operations)

I hope it's clear :-)

Thanks,
Julien

--
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.

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

<<attachment: jcigar.vcf>>

Reply via email to