[Erp5-report] r15665 - /erp5/trunk/products/ERP5SyncML/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Aug 14 13:43:44 CEST 2007
Author: fabien
Date: Tue Aug 14 13:43:44 2007
New Revision: 15665
URL: http://svn.erp5.org?rev=15665&view=rev
Log:
add the user management :
- the modification (Add, Replace, Delete) on subscription are made under the
user logged in zope at the begening of the synchro.
- the modification on publication are made under the user send by the
subscriber (the login and password fields in subscription).
Modified:
erp5/trunk/products/ERP5SyncML/Subscription.py
erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py
erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py
Modified: erp5/trunk/products/ERP5SyncML/Subscription.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Subscription.py?rev=15665&r1=15664&r2=15665&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Subscription.py (original)
+++ erp5/trunk/products/ERP5SyncML/Subscription.py Tue Aug 14 13:43:44 2007
@@ -999,6 +999,18 @@
"""
self.password = new_password
+ def getZopeUser(self):
+ """
+ This method return the zope user who begin the synchronization session
+ """
+ return getattr(self, 'zope_user_name', None)
+
+ def setZopeUser(self, user_name):
+ """
+ This method set the zope user_name
+ """
+ self.zope_user_name = user_name
+
def getAuthenticationFormat(self):
"""
return the format of authentication
@@ -1052,6 +1064,9 @@
This tries to get the object with the given gid
This uses the query if it exist
"""
+ #if len(gid)%2 != 0:
+ #something encode in base 16 is always a even number of number
+ # return None
signature = self.getSignatureFromGid(gid)
# First look if we do already have the mapping between
# the id and the gid
Modified: erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py?rev=15665&r1=15664&r2=15665&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py (original)
+++ erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py Tue Aug 14 13:43:44 2007
@@ -44,6 +44,13 @@
cmd_id = 1 # specifies a SyncML message-unique command identifier
subscription.NewAnchor()
subscription.initLastMessageId()
+
+ #save the actual user to use it in all the session:
+ user = self.portal_membership.getAuthenticatedMember().getUserName()
+ LOG('SubSyncInit, user saved :',DEBUG, user)
+ subscription.setZopeUser(user)
+ subscription.setAuthenticated(True)
+
xml_list = []
xml = xml_list.append
xml('<SyncML>\n')
Modified: erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/SynchronizationTool.py?rev=15665&r1=15664&r2=15665&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/SynchronizationTool.py (original)
+++ erp5/trunk/products/ERP5SyncML/SynchronizationTool.py Tue Aug 14 13:43:44 2007
@@ -984,6 +984,9 @@
LOG('sync, message_list:', DEBUG, message_list)
if len(message_list) == 0:
for subscription in self.getSubscriptionList():
+ user = subscription.getZopeUser()
+ LOG('sync, user :',DEBUG, user)
+ newSecurityManager(None, user)
LOG('sync, type(subcription):', DEBUG, type(subscription))
self.activate(activity='RAMQueue').SubSync(subscription.getPath())
@@ -1001,6 +1004,7 @@
# the id sync_id, this is not so good, but there is no way yet
# to know if we will call a publication or subscription XXX
gpg_key = ''
+ LOG('readResponse, sync_id :', DEBUG, sync_id)
for publication in self.getPublicationList():
if publication.getTitle() == sync_id:
gpg_key = publication.getGPGKey()
@@ -1010,6 +1014,9 @@
if subscription.getTitle() == sync_id:
gpg_key = subscription.getGPGKey()
domain = subscription
+ user = domain.getZopeUser()
+ LOG('readResponse, user :', DEBUG, user)
+ newSecurityManager(None, user)
# decrypt the message if needed
if gpg_key not in (None,''):
filename = str(random.randrange(1, 2147483600)) + '.txt'
Modified: erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py?rev=15665&r1=15664&r2=15665&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py (original)
+++ erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py Tue Aug 14 13:43:44 2007
@@ -1241,6 +1241,7 @@
elif status_code in (self.SUCCESS, self.ITEM_ADDED):
signature.setStatus(self.SYNCHRONIZED)
elif status_cmd == 'Delete':
+ has_status_list = 1
if status_code == self.SUCCESS:
signature = subscriber.getSignatureFromGid(object_gid) or \
subscriber.getSignatureFromRid(object_gid)
@@ -1494,11 +1495,14 @@
xml=xml_a,
domain=domain,
content_type=domain.getSyncContentType())
+ if syncml_data == '':
+ LOG('this is the end of the synchronisation session !!!', DEBUG, '')
+ subscriber.setAuthenticated(False)
+ domain.setAuthenticated(False)
has_response = 1
elif domain.domain_type == self.SUB:
if self.checkAlert(remote_xml) or \
- (xml_confirmation,syncml_data) != ('','') or \
- has_status_list:
+ (xml_confirmation,syncml_data) != ('',''):
subscriber.setLastSentMessage(xml_a)
self.sendResponse(
from_url=domain.subscription_url,
@@ -1507,6 +1511,9 @@
xml=xml_a,domain=domain,
content_type=domain.getSyncContentType())
has_response = 1
+ else:
+ LOG('this is the end of the synchronisation session !!!', DEBUG, '')
+ domain.setAuthenticated(False)
return {'has_response':has_response,'xml':xml_a}
def xml2wbxml(self, xml):
More information about the Erp5-report
mailing list