Hello zope3-users,

I am trying to do make easy user registrations for my website. but I am having problems assigning roles to the principals automatically. the question is WHEN should I assign these roles to the new principals? which is the standard procedure?
right now I am doing :

1. User accounts (InternalPrincipal) are created.
2. The first time the user logs in a role with id="isi.member" will be assigned to it on the whole site so the user receives membership permissions.


*********************************************configure.zcml*****************************************************
 <subscriber
     handler=".userhome.UserLoggedIn"
for="zope.app.authentication.interfaces.IAuthenticatedPrincipalCreated"
 />

*********************************************userhome.py********************************************************

class UserLoggedIn(object):
def __init__(self, event): userAnno=zapi.getUtility(IPrincipalAnnotationUtility, 'ISIUserAnnotation')
       annotations=userAnno.getAnnotations(event.principal)
if annotations.get('user_home') is None:
           print "***************RGISTERING ANNOTATIONS*****************"
           annotations['user_home'] = Folder()
           annotations['user_home']['register'] = PersistentDict()
           annotations['user_home']['personal'] = Person()
           annotations['user_home']['personal'].first='hassan'
           annotations['user_home']['personal'].last='alirezaei'
           annotations['user_home']['testing'] = "TESTING THE NEW USER"
siteroot=getSite()
           prm=IPrincipalRoleManager(siteroot)
           print "******************for %s *******************" %siteroot
           prm.assignRoleToPrincipal('isi.member', event.principal)



******************************************************************************************************

getSite() gives me <ISI.isi.isi.isi object at 0xb659eb2c> but when i go to this object (my main site root) and change to "Grant" from zmi_actions menu the role is still unset for the user.

any help is highly appreciated. it is very much possible I am doing the hard way to perform the task.
Thank you in advance!

Hass







_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to