Skip to content

Commit

Permalink
Make replication POST-only
Browse files Browse the repository at this point in the history
Don't trigger a replication when restarting a browser session ..
  • Loading branch information
jean committed Sep 9, 2013
1 parent af959d6 commit 5612bf5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Products/CMFPlomino/PlominoReplicationManager.py
Expand Up @@ -145,6 +145,7 @@ class PlominoReplicationManager(Persistent):

# Methods
security.declareProtected(EDIT_PERMISSION, 'manage_replications')
@postonly
def manage_replications(self, REQUEST=None):
""" Replication form manager
"""
Expand Down Expand Up @@ -253,6 +254,7 @@ def manage_replications(self, REQUEST=None):
REQUEST.RESPONSE.redirect(self.absolute_url()+'/DatabaseReplication')

security.declareProtected(EDIT_PERMISSION, 'deleteReplications')
@postonly
def deleteReplications(self, replicationIds):
""" Delete remoteUrl list
"""
Expand Down Expand Up @@ -286,6 +288,7 @@ def deleteReplications(self, replicationIds):
return infoMsg

security.declareProtected(EDIT_PERMISSION, 'saveReplication')
@postonly
def saveReplication(self, REQUEST=None):
""" Save replication
"""
Expand All @@ -302,6 +305,7 @@ def saveReplication(self, REQUEST=None):
return "replication saved"

security.declareProtected(EDIT_PERMISSION, 'replicate')
@postonly
def replicate(self, replicationId=None):
""" Launch replication with just remote URL passed
"""
Expand All @@ -326,6 +330,7 @@ def replicate(self, replicationId=None):
return infoMsg

security.declareProtected(EDIT_PERMISSION, 'launchReplication')
@postonly
def launchReplication(self, replication):
""" Launch replication with params
"""
Expand Down Expand Up @@ -637,6 +642,7 @@ def importableDoc(self, docId, lastEditRemoteDocumentDate, lastReplicationDate,
return result

security.declarePrivate('importDocumentPull')
@postonly
def importDocumentPull(self, i, remoteUrl, username, password):
""" Imports document from remoteurl.
Send object as a .zexp stream via HTTP multipart POST
Expand All @@ -658,6 +664,7 @@ def getReplications(self):
return self.replicationHistory

security.declareProtected(EDIT_PERMISSION, 'setReplications')
@postonly
def setReplications(self, replications):
""" Sets the replications hashmap.
"""
Expand Down Expand Up @@ -688,6 +695,7 @@ def getReplication(self, search_id):
return result

security.declarePrivate('setReplication')
@postonly
def setReplication(self, replication):
""" Add the replication to the replication hashmap.
"""
Expand All @@ -708,6 +716,7 @@ def getReplicationsDates(self):
return self.replicationsDates

security.declareProtected(EDIT_PERMISSION, 'setReplicationsDates')
@postonly
def setReplicationsDates(self, replication_dates):
""" Sets the replications hashmap
"""
Expand Down Expand Up @@ -744,6 +753,7 @@ def getReplicationDate(self, remoteUrl, replicationtype):
return replication_dates[remoteUrl][replicationtype]

security.declarePrivate('setReplicationDate')
@postonly
def setReplicationDate(self, remoteUrl, replicationtype, date):
""" Sets the replication date for URL and type
"""
Expand Down Expand Up @@ -805,6 +815,7 @@ def displayDates(self, remoteUrl, context):
return result

security.declarePrivate('setReplicationMode')
@postonly
def setReplicationMode(self, remoteId, mode):
""" Sets the replication mode for URL
"""
Expand Down Expand Up @@ -833,6 +844,7 @@ def setReplicationMode(self, remoteId, mode):
self.setReplication(replication)

security.declarePublic('startReplicationRemote')
@postonly
def startReplicationRemote(self, REQUEST=None):
""" Flags the start of the transaction (remote).
"""
Expand All @@ -845,6 +857,7 @@ def startReplicationRemote(self, REQUEST=None):
self.startReplication(remoteUrl, repType)

security.declarePublic('startReplication')
@postonly
def startReplication(self, remoteUrl, repType):
""" Flags the start of the transaction (local).
"""
Expand Down Expand Up @@ -873,6 +886,7 @@ def displayItNice(self, key, hashmap_name):
return result

security.declarePublic('resetReplications')
@postonly
def resetReplications(self):
""" Reset the replication hashmap
"""
Expand Down Expand Up @@ -1008,6 +1022,7 @@ def checkReplication(self, replication):
return replication

security.declareProtected(EDIT_PERMISSION, 'manage_importation')
@postonly
def manage_importation(self, REQUEST=None):
""" CSV import form manager.
"""
Expand Down Expand Up @@ -1040,6 +1055,7 @@ def getSeparators(self):
return PLOMINO_IMPORT_SEPARATORS

security.declareProtected(EDIT_PERMISSION, 'processImport')
@postonly
def processImport(self, REQUEST):
""" Process the importation.
"""
Expand Down Expand Up @@ -1091,6 +1107,7 @@ def processImport(self, REQUEST):
return infoMsg

security.declareProtected(EDIT_PERMISSION, 'processImport')
@postonly
def processImportAPI(self, formName, separator, fileToImport, file_encoding='utf-8'):
""" Process import API method.
"""
Expand Down Expand Up @@ -1165,6 +1182,7 @@ def parseFile(self, fileToImport, formName, separator, file_encoding='utf-8'):
raise PlominoReplicationException, 'error while parsing file (%s)' % (e)

security.declareProtected(EDIT_PERMISSION, 'importCsv')
@postonly
def importCsv(self, fileContent):
""" Import CSV from content parsed.
"""
Expand Down Expand Up @@ -1250,6 +1268,7 @@ def addToReport(self, lineNumber, infoMessage, error=False):
'infoMsg': infoMessage})

security.declareProtected(READ_PERMISSION, 'manage_exportAsXML')
@postonly
def manage_exportAsXML(self, REQUEST):
"""
"""
Expand Down Expand Up @@ -1372,6 +1391,7 @@ def exportDocumentAsXML(self, xmldoc, doc):
return node

security.declareProtected(REMOVE_PERMISSION, 'manage_importFromXML')
@postonly
def manage_importFromXML(self, REQUEST):
"""
"""
Expand All @@ -1384,6 +1404,7 @@ def manage_importFromXML(self, REQUEST):
REQUEST.RESPONSE.redirect(self.absolute_url()+"/DatabaseReplication")

security.declareProtected(REMOVE_PERMISSION, 'importFromXML')
@postonly
def importFromXML(self, xmlstring=None, sourcetype='sourceFile', from_file=None, from_folder=None, REQUEST=None):
""" Import documents from XML.
The sourcetype can be sourceFile or sourceFolder.
Expand Down Expand Up @@ -1470,6 +1491,7 @@ def importFromXML(self, xmlstring=None, sourcetype='sourceFile', from_file=None,
return (imports, errors)

security.declareProtected(CREATE_PERMISSION, 'importDocumentFromXML')
@postonly
def importDocumentFromXML(self, node):
docid = node.getAttribute('id').encode('ascii')
lastmodified = DateTime(node.getAttribute('lastmodified'))
Expand Down

0 comments on commit 5612bf5

Please sign in to comment.