server/repository.py
changeset 594 76218d42d21f
parent 479 ac5c9442b1fd
child 636 3e9245cf0d9c
child 1160 77bf88f01fcc
equal deleted inserted replaced
593:6f6549780096 594:76218d42d21f
   488         registration on public web site.
   488         registration on public web site.
   489         """
   489         """
   490         session = self.internal_session()
   490         session = self.internal_session()
   491         try:
   491         try:
   492             if session.execute('EUser X WHERE X login %(login)s', {'login': login}):
   492             if session.execute('EUser X WHERE X login %(login)s', {'login': login}):
   493                 return
   493                 return False
   494             # we have to create the user
   494             # we have to create the user
   495             user = self.vreg.etype_class('EUser')(session, None)
   495             user = self.vreg.etype_class('EUser')(session, None)
   496             if isinstance(password, unicode):
   496             if isinstance(password, unicode):
   497                 # password should *always* be utf8 encoded
   497                 # password should *always* be utf8 encoded
   498                 password = password.encode('UTF8')
   498                 password = password.encode('UTF8')
   503             session.execute('SET X in_group G WHERE X eid %(x)s, G name "users"',
   503             session.execute('SET X in_group G WHERE X eid %(x)s, G name "users"',
   504                             {'x': user.eid})
   504                             {'x': user.eid})
   505             session.commit()
   505             session.commit()
   506         finally:
   506         finally:
   507             session.close()
   507             session.close()
       
   508         return True
   508         
   509         
   509     def connect(self, login, password, cnxprops=None):
   510     def connect(self, login, password, cnxprops=None):
   510         """open a connection for a given user
   511         """open a connection for a given user
   511 
   512 
   512         base_url may be needed to send mails
   513         base_url may be needed to send mails