Commit 7c6cfa90 authored by Nicolas Delaby's avatar Nicolas Delaby

add the property activity_enabled


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15038 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a80a8cdd
...@@ -152,14 +152,15 @@ class Publication(Subscription): ...@@ -152,14 +152,15 @@ class Publication(Subscription):
constructors = (addPublication,) constructors = (addPublication,)
# Constructor # Constructor
def __init__(self, id, title, publication_url, destination_path, source_uri, def __init__(self, id, title, publication_url, destination_path,
query, xml_mapping, conduit, gpg_key, id_generator, gid_generator, source_uri, query, xml_mapping, conduit, gpg_key, id_generator,
media_type, auth_required=False, authentication_format='', gid_generator, media_type, auth_required, authentication_format,
authentication_type=''): authentication_type, activity_enabeled):
""" """
constructor constructor
""" """
self.id = id self.id = id
self.setActivityEnabeled(activity_enabeled)
self.publication_url = publication_url self.publication_url = publication_url
self.destination_path = destination_path self.destination_path = destination_path
self.setSourceURI(source_uri) self.setSourceURI(source_uri)
...@@ -178,6 +179,18 @@ class Publication(Subscription): ...@@ -178,6 +179,18 @@ class Publication(Subscription):
self.authentication_format = authentication_format self.authentication_format = authentication_format
self.authentication_type = authentication_type self.authentication_type = authentication_type
def getActivityEnabeled(self):
"""
return true if we are using activity, false otherwise
"""
return getattr(self, 'activity_enabeled', None)
def setActivityEnabeled(self, activity_enabeled):
"""
set if we are using activity or not
"""
self.activity_enabeled = activity_enabeled
def getPublicationUrl(self): def getPublicationUrl(self):
""" """
return the publication url return the publication url
......
...@@ -1017,13 +1017,13 @@ class Subscription(Folder, SyncCode): ...@@ -1017,13 +1017,13 @@ class Subscription(Folder, SyncCode):
# First look if we do already have the mapping between # First look if we do already have the mapping between
# the id and the gid # the id and the gid
#XXX Slow !!! #XXX Slow !!!
object_list = self.getObjectList() object_list = self.getObjectList(gid=gid)
destination = self.getDestination() destination = self.getDestination()
if signature is not None and signature.getObjectId() is not None: if signature is not None and signature.getPath() is not None:
o_id = signature.getObjectId() o_id = signature.getObjectId()
o = None o = None
try: try:
o = destination._getOb(o_id) o = destination.getPortalObject().restrictedTraverse(signature.getPath())
except (AttributeError, KeyError, TypeError): except (AttributeError, KeyError, TypeError):
pass pass
if o is not None and o in object_list: if o is not None and o in object_list:
...@@ -1039,7 +1039,7 @@ class Subscription(Folder, SyncCode): ...@@ -1039,7 +1039,7 @@ class Subscription(Folder, SyncCode):
""" """
return the object corresponding to the id return the object corresponding to the id
""" """
object_list = self.getObjectList() object_list = self.getObjectList(id=id)
#XXX very slow with lot of objects #XXX very slow with lot of objects
o = None o = None
for object in object_list: for object in object_list:
...@@ -1057,7 +1057,7 @@ class Subscription(Folder, SyncCode): ...@@ -1057,7 +1057,7 @@ class Subscription(Folder, SyncCode):
# #
def getObjectList(self): def getObjectList(self, **kw):
""" """
This returns the list of sub-object corresponding This returns the list of sub-object corresponding
to the query to the query
...@@ -1065,13 +1065,11 @@ class Subscription(Folder, SyncCode): ...@@ -1065,13 +1065,11 @@ class Subscription(Folder, SyncCode):
destination = self.getDestination() destination = self.getDestination()
query = self.getQuery() query = self.getQuery()
query_list = [] query_list = []
if query is None: if query is not None and isinstance(query, str):
return query_list
if isinstance(query, str):
query_method = getattr(destination,query,None) query_method = getattr(destination,query,None)
if query_method is not None: if query_method is not None:
query_list = query_method() query_list = query_method(**kw)
elif callable(query): # XXX - used to be if callable(query) elif callable(query): # used in the test
query_list = query(destination) query_list = query(destination)
return [x for x in query_list return [x for x in query_list
if not getattr(x,'_conflict_resolution',False)] if not getattr(x,'_conflict_resolution',False)]
......
...@@ -74,6 +74,7 @@ class TimeoutHTTPHandler(urllib2.HTTPHandler): ...@@ -74,6 +74,7 @@ class TimeoutHTTPHandler(urllib2.HTTPHandler):
return self.do_open(TimeoutHTTPConnection, req) return self.do_open(TimeoutHTTPConnection, req)
class SynchronizationTool( SubscriptionSynchronization, class SynchronizationTool( SubscriptionSynchronization,
PublicationSynchronization, UniqueObject, Folder): PublicationSynchronization, UniqueObject, Folder):
""" """
...@@ -173,11 +174,11 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -173,11 +174,11 @@ class SynchronizationTool( SubscriptionSynchronization,
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'manage_addPublication') 'manage_addPublication')
def manage_addPublication(self, title, publication_url, destination_path, def manage_addPublication(self, title, publication_url,
source_uri, query, xml_mapping, conduit, gpg_key, destination_path, source_uri, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator=None, gid_generator=None, synchronization_id_generator=None, gid_generator=None,
media_type=None, auth_required=0, authentication_format='', media_type=None, auth_required=0, authentication_format='',
authentication_type='', RESPONSE=None): authentication_type='', RESPONSE=None, activity_enabeled = False):
""" """
create a new publication create a new publication
""" """
...@@ -186,10 +187,11 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -186,10 +187,11 @@ class SynchronizationTool( SubscriptionSynchronization,
# self._setObject(publications.id, publications) # self._setObject(publications.id, publications)
folder = self.getObjectContainer() folder = self.getObjectContainer()
new_id = self.getPublicationIdFromTitle(title) new_id = self.getPublicationIdFromTitle(title)
pub = Publication(new_id, title, publication_url, destination_path, pub = Publication(new_id, title, publication_url,
source_uri, query, xml_mapping, conduit, gpg_key, destination_path, source_uri, query, xml_mapping,
synchronization_id_generator, gid_generator, media_type, conduit, gpg_key, synchronization_id_generator,
auth_required, authentication_format, authentication_type) gid_generator, media_type, auth_required,
authentication_format, authentication_type, activity_enabeled)
folder._setObject( new_id, pub ) folder._setObject( new_id, pub )
#if len(self.list_publications) == 0: #if len(self.list_publications) == 0:
# self.list_publications = PersistentMapping() # self.list_publications = PersistentMapping()
...@@ -228,17 +230,18 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -228,17 +230,18 @@ class SynchronizationTool( SubscriptionSynchronization,
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'manage_editPublication') 'manage_editPublication')
def manage_editPublication(self, title, publication_url, destination_path, def manage_editPublication(self, title, publication_url,
source_uri, query, xml_mapping, conduit, gpg_key, destination_path, source_uri, query, xml_mapping,
synchronization_id_generator, gid_generator, conduit, gpg_key, synchronization_id_generator,
media_type=None, auth_required=0, gid_generator, media_type=None, auth_required=0,
authentication_format='', authentication_type='', authentication_format='', authentication_type='',
RESPONSE=None): RESPONSE=None, activity_enabeled=False):
""" """
modify a publication modify a publication
""" """
pub = self.getPublication(title) pub = self.getPublication(title)
pub.setTitle(title) pub.setTitle(title)
pub.setActivityEnabeled(activity_enabeled)
pub.setPublicationUrl(publication_url) pub.setPublicationUrl(publication_url)
pub.setDestinationPath(destination_path) pub.setDestinationPath(destination_path)
pub.setSourceURI(source_uri) pub.setSourceURI(source_uri)
...@@ -970,7 +973,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -970,7 +973,7 @@ class SynchronizationTool( SubscriptionSynchronization,
We will look at the url and we will see if we need to send mail, http We will look at the url and we will see if we need to send mail, http
response, or just copy to a file. response, or just copy to a file.
""" """
LOG('readResponse, text :', 0, text) #LOG('readResponse, text :', 0, text)
# Login as a manager to make sure we can create objects # Login as a manager to make sure we can create objects
uf = self.acl_users uf = self.acl_users
user = uf.getUserById('syncml').__of__(uf) user = uf.getUserById('syncml').__of__(uf)
......
...@@ -1072,6 +1072,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -1072,6 +1072,7 @@ class XMLSyncUtilsMixin(SyncCode):
if conflict_list != [] and signature is not None: if conflict_list != [] and signature is not None:
# We had a conflict # We had a conflict
signature.setStatus(self.CONFLICT) signature.setStatus(self.CONFLICT)
return (xml_confirmation,has_next_action,cmd_id) return (xml_confirmation,has_next_action,cmd_id)
def applyStatusList(self, subscriber=None,remote_xml=None): def applyStatusList(self, subscriber=None,remote_xml=None):
......
...@@ -47,6 +47,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -47,6 +47,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="title" value="<dtml-var getTitle>" size="40"/> <input type="text" name="title" value="<dtml-var getTitle>" size="40"/>
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Use Activity
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="activity_enabeled" value="1" <dtml-if expr="getActivityEnabeled()">CHECKED</dtml-if>>
</td>
</tr>
<tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -43,6 +43,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -43,6 +43,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="title" size="40" /> <input type="text" name="title" size="40" />
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Use Activity
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="activity_enabeled" value="1">
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -346,7 +346,8 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): ...@@ -346,7 +346,8 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase):
xml_mapping=self.xml_mapping, xml_mapping=self.xml_mapping,
conduit='ERP5Conduit', conduit='ERP5Conduit',
gpg_key='', gpg_key='',
gid_generator='getId') gid_generator='getId',
activity_enabeled=False)
pub = portal_sync.getPublication(self.pub_id) pub = portal_sync.getPublication(self.pub_id)
self.failUnless(pub is not None) self.failUnless(pub is not None)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment