il devrait (c'est pas testé) être maintenant possible d'avoir des

identités/fiches personnes/comptes privés et que l'envoi du mot de passe par
email fonctionne qd même
This commit is contained in:
fpeters 2004-03-24 15:20:09 +00:00
parent b23719bb5a
commit ea2ac8aa85
8 changed files with 87 additions and 9 deletions

View File

@ -434,6 +434,18 @@ class IdentitiesServer(commonIdentities.IdentitiesCommonMixin,
return identityIdentification.localNameIdentifier
return None
def getObjectEmail(self, objectId):
virtualServerId = context.getVar('applicationId')
virtualServer = self.getVirtualServer(virtualServerId)
object = virtualServer.loadObjectCore(objectId)
if not object.personId:
return ''
from glasnost.proxy.tools import getProxy
personProxy = getProxy(object.personId)
return personProxy.getObjectEmail(object.personId)
def getObjectLabelAndLanguageXmlRpc(self, objectId):
virtualServerId = context.getVar('applicationId')
virtualServer = self.getVirtualServer(virtualServerId)
@ -535,6 +547,7 @@ class IdentitiesServer(commonIdentities.IdentitiesCommonMixin,
self.registerPublicMethod('getElectionVoteToken')
self.registerPublicMethod('getLocalNameIdentifierIdentityProvider')
self.registerPublicMethod('getLocalNameIdentifierServiceProvider')
self.registerPublicMethod('getObjectEmail')
self.registerPublicMethod('getPeerNameIdentifierIdentityProvider')
self.registerPublicMethod('getPeerNameIdentifierServiceProvider')
self.registerPublicMethod('getPersonId')

View File

@ -159,6 +159,24 @@ class NCardsServer(NCardsCommonMixin, ObjectsServer):
return applicationName
raise 'aie'
def getObjectEmail(self, objectId):
clientToken = context.getVar('clientToken')
clientId = getApplicationId(clientToken)
clientRole = commonTools.extractRole(clientId)
if clientRole != 'identities':
raise faults.ApplicationAccessDenied(clientId)
virtualServerId = context.getVar('applicationId')
virtualServer = self.getVirtualServer(virtualServerId)
object = virtualServer.loadObjectCore(objectId)
emailAddress = object.getEmail()
if not emailAddress:
return '' # or raise something ?
return emailAddress
def loadVirtualServer(self, virtualServer):
# ObjectsServer.loadVirtualServer; modified to user ncard.objectName
# instead of self.applicationName
@ -273,6 +291,7 @@ class NCardsServer(NCardsCommonMixin, ObjectsServer):
def registerPublicMethods(self):
ObjectsServer.registerPublicMethods(self)
self.registerPublicMethod('getObjectEmail')
self.registerPublicMethod('getObjectIdByRole')
def pushContext(self, virtualServerId, clientToken, userToken):

View File

@ -254,22 +254,22 @@ class PasswordAccountsServer(
if not identity.personId:
print 'no personId for this identity'
return
person = getObject(identity.personId)
emailAddress = person.getEmail()
emailAddress = identitiesProxy.getObjectEmail(object.identityId)
if not emailAddress:
raise faults.BadEmailAddress('')
personProxy = getProxyForServerRole(
commonTools.extractRole(identity.personId))
personName, personLanguage = personProxy.getObjectLabelAndLanguage(
identity.personId)
toAddress = [emailAddress]
password = object.password
language = object.getLanguage()
if not language:
language = 'en'
messageFileName = commonTools.getConfig(
commonTools.extractDispatcherId(object.id),
'WelcomeEmail-%s' % language)
'WelcomeEmail-%s' % personLanguage)
messageSubject = commonTools.getConfig(
commonTools.extractDispatcherId(object.id),
'WelcomeEmailSubject',
@ -294,7 +294,7 @@ The Glasnost administrator - %(fromAddress)s
virtualServerId)
fromAddresses = self.getAdminEmailAddresses(stopAsap = 1)
message = message % {
'user': person.getLabel(),
'user': personName,
'fromAddress': fromAddresses[0],
'hostName': hostName,
'login': object.login,

View File

@ -283,6 +283,24 @@ class PeopleServer(PeopleCommonMixin, ObjectsServer):
if object.containsText(text):
foundIds.append(objectId)
return foundIds
def getObjectEmail(self, objectId):
clientToken = context.getVar('clientToken')
clientId = getApplicationId(clientToken)
clientRole = commonTools.extractRole(clientId)
if clientRole != 'identities':
raise faults.ApplicationAccessDenied(clientId)
virtualServerId = context.getVar('applicationId')
virtualServer = self.getVirtualServer(virtualServerId)
object = virtualServer.loadObjectCore(objectId)
emailAddress = object.getEmail()
if not emailAddress:
return '' # or raise something ?
return emailAddress
def getObjectStringFromDigestXmlRpc(self, objectId, path, digest):
"""Retrieve a string in the specified object from its MD5 digest.
@ -413,6 +431,7 @@ class PeopleServer(PeopleCommonMixin, ObjectsServer):
ObjectsServer.registerPublicMethods(self)
self.registerPublicMethod('findObjectIds', self.findObjectIdsXmlRpc)
self.registerPublicMethod('getObjectEmail')
def repairVirtualServer(self, virtualServer, version):
"""Handle a descendant compatibily with older server datas.

View File

@ -165,6 +165,7 @@ class NCardNCardCommon(ObjectCommon):
def getEmail(self):
if hasattr(self, 'email'):
return getattr(self, 'email')
# TODO: look up an attr with kind 'Email'
return None
def getLabel(self):

View File

@ -176,6 +176,14 @@ class IdentitiesProxy(commonIdentities.IdentitiesCommonMixin,
'getLocalNameIdentifierServiceProvider',
[serverId, getApplicationToken(), userToken, peerHostName])
def getObjectEmail(self, objectId):
userToken = context.getVar('userToken', default = '')
return callServer(
commonTools.extractServerId(objectId),
'getObjectEmail',
[commonTools.extractServerId(objectId), getApplicationToken(),
userToken, objectId])
def getPeerNameIdentifierIdentityProvider(
self, peerHostName, serverId = None):
userToken = context.getVar('userToken', default = '')

View File

@ -64,6 +64,15 @@ class NCard(ObjectProxyMixin, NCardCommon):
register(NCard)
class NCardsObjectsProxy(ObjectsProxy):
def getObjectEmail(self, objectId):
userToken = context.getVar('userToken', default = '')
return callServer(
commonTools.extractServerId(objectId),
'getObjectEmail',
[commonTools.extractServerId(objectId), getApplicationToken(),
userToken, objectId])
class NCardsProxy(NCardsCommonMixin, ObjectsProxy):
def getObjectIdByRole(self, role, serverId = None):
userToken = context.getVar('userToken', default = '')
@ -95,7 +104,7 @@ def getProxyClass(ncard):
objectsClass = new.classobj(
commonMixinClass.__name__,
(commonMixinClass, ObjectsProxy),
(commonMixinClass, NCardsObjectsProxy),
{'adminClass': objectAdminClass,
'objectClass': objectClass})

View File

@ -93,3 +93,12 @@ class PeopleProxy(PeopleCommonMixin, ObjectsProxy):
'findObjectIds',
[serverId, getApplicationToken(), userToken, utf8(text)])
def getObjectEmail(self, objectId):
userToken = context.getVar('userToken', default = '')
return callServer(
commonTools.extractServerId(objectId),
'getObjectEmail',
[commonTools.extractServerId(objectId), getApplicationToken(),
userToken, objectId])