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):
constructors = (addPublication,)
# Constructor
def __init__(self, id, title, publication_url, destination_path, source_uri,
query, xml_mapping, conduit, gpg_key, id_generator, gid_generator,
media_type, auth_required=False, authentication_format='',
authentication_type=''):
def __init__(self, id, title, publication_url, destination_path,
source_uri, query, xml_mapping, conduit, gpg_key, id_generator,
gid_generator, media_type, auth_required, authentication_format,
authentication_type, activity_enabeled):
"""
constructor
"""
self.id = id
self.setActivityEnabeled(activity_enabeled)
self.publication_url = publication_url
self.destination_path = destination_path
self.setSourceURI(source_uri)
......@@ -178,6 +179,18 @@ class Publication(Subscription):
self.authentication_format = authentication_format
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):
"""
return the publication url
......
......@@ -1017,13 +1017,13 @@ class Subscription(Folder, SyncCode):
# First look if we do already have the mapping between
# the id and the gid
#XXX Slow !!!
object_list = self.getObjectList()
object_list = self.getObjectList(gid=gid)
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 = None
try:
o = destination._getOb(o_id)
o = destination.getPortalObject().restrictedTraverse(signature.getPath())
except (AttributeError, KeyError, TypeError):
pass
if o is not None and o in object_list:
......@@ -1039,7 +1039,7 @@ class Subscription(Folder, SyncCode):
"""
return the object corresponding to the id
"""
object_list = self.getObjectList()
object_list = self.getObjectList(id=id)
#XXX very slow with lot of objects
o = None
for object in object_list:
......@@ -1057,7 +1057,7 @@ class Subscription(Folder, SyncCode):
#
def getObjectList(self):
def getObjectList(self, **kw):
"""
This returns the list of sub-object corresponding
to the query
......@@ -1065,13 +1065,11 @@ class Subscription(Folder, SyncCode):
destination = self.getDestination()
query = self.getQuery()
query_list = []
if query is None:
return query_list
if isinstance(query, str):
if query is not None and isinstance(query, str):
query_method = getattr(destination,query,None)
if query_method is not None:
query_list = query_method()
elif callable(query): # XXX - used to be if callable(query)
query_list = query_method(**kw)
elif callable(query): # used in the test
query_list = query(destination)
return [x for x in query_list
if not getattr(x,'_conflict_resolution',False)]
......
......@@ -74,6 +74,7 @@ class TimeoutHTTPHandler(urllib2.HTTPHandler):
return self.do_open(TimeoutHTTPConnection, req)
class SynchronizationTool( SubscriptionSynchronization,
PublicationSynchronization, UniqueObject, Folder):
"""
......@@ -173,11 +174,11 @@ class SynchronizationTool( SubscriptionSynchronization,
security.declareProtected(Permissions.ModifyPortalContent,
'manage_addPublication')
def manage_addPublication(self, title, publication_url, destination_path,
source_uri, query, xml_mapping, conduit, gpg_key,
def manage_addPublication(self, title, publication_url,
destination_path, source_uri, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator=None, gid_generator=None,
media_type=None, auth_required=0, authentication_format='',
authentication_type='', RESPONSE=None):
authentication_type='', RESPONSE=None, activity_enabeled = False):
"""
create a new publication
"""
......@@ -186,10 +187,11 @@ class SynchronizationTool( SubscriptionSynchronization,
# self._setObject(publications.id, publications)
folder = self.getObjectContainer()
new_id = self.getPublicationIdFromTitle(title)
pub = Publication(new_id, title, publication_url, destination_path,
source_uri, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator, gid_generator, media_type,
auth_required, authentication_format, authentication_type)
pub = Publication(new_id, title, publication_url,
destination_path, source_uri, query, xml_mapping,
conduit, gpg_key, synchronization_id_generator,
gid_generator, media_type, auth_required,
authentication_format, authentication_type, activity_enabeled)
folder._setObject( new_id, pub )
#if len(self.list_publications) == 0:
# self.list_publications = PersistentMapping()
......@@ -228,17 +230,18 @@ class SynchronizationTool( SubscriptionSynchronization,
security.declareProtected(Permissions.ModifyPortalContent,
'manage_editPublication')
def manage_editPublication(self, title, publication_url, destination_path,
source_uri, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator, gid_generator,
media_type=None, auth_required=0,
authentication_format='', authentication_type='',
RESPONSE=None):
def manage_editPublication(self, title, publication_url,
destination_path, source_uri, query, xml_mapping,
conduit, gpg_key, synchronization_id_generator,
gid_generator, media_type=None, auth_required=0,
authentication_format='', authentication_type='',
RESPONSE=None, activity_enabeled=False):
"""
modify a publication
"""
pub = self.getPublication(title)
pub.setTitle(title)
pub.setActivityEnabeled(activity_enabeled)
pub.setPublicationUrl(publication_url)
pub.setDestinationPath(destination_path)
pub.setSourceURI(source_uri)
......@@ -970,7 +973,7 @@ class SynchronizationTool( SubscriptionSynchronization,
We will look at the url and we will see if we need to send mail, http
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
uf = self.acl_users
user = uf.getUserById('syncml').__of__(uf)
......
......@@ -1072,6 +1072,7 @@ class XMLSyncUtilsMixin(SyncCode):
if conflict_list != [] and signature is not None:
# We had a conflict
signature.setStatus(self.CONFLICT)
return (xml_confirmation,has_next_action,cmd_id)
def applyStatusList(self, subscriber=None,remote_xml=None):
......
......@@ -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"/>
</td>
</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>
<td align="left" valign="top">
<div class="form-label">
......
......@@ -43,6 +43,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="title" size="40" />
</td>
</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>
<td align="left" valign="top">
<div class="form-label">
......
......@@ -346,7 +346,8 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase):
xml_mapping=self.xml_mapping,
conduit='ERP5Conduit',
gpg_key='',
gid_generator='getId')
gid_generator='getId',
activity_enabeled=False)
pub = portal_sync.getPublication(self.pub_id)
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