Commit c677aa39 authored by Jérome Perrin's avatar Jérome Perrin

make sure we have been provided a good ip:port node reference before adding it

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6338 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 961793b1
......@@ -46,6 +46,7 @@ import sys
from ZODB.POSException import ConflictError
from OFS.Traversable import NotFound
from types import TupleType, StringType
import re
from zLOG import LOG, INFO, WARNING
......@@ -55,6 +56,9 @@ except ImportError:
def getTimerService(self):
pass
# minimal IP:Port regexp
NODE_RE = re.compile('\d+\.\d+\.\d+\.\d:\d+')
# Using a RAM property (not a property of an instance) allows
# to prevent from storing a state in the ZODB (and allows to restart...)
active_threads = 0
......@@ -372,24 +376,44 @@ class ActivityTool (Folder, UniqueObject):
""" Return the distributingNode """
return self.distributingNode
security.declarePublic('getNodeList')
security.declarePublic('getNodeList getNodes')
def getNodes(self):
""" Return all nodes """
return self._nodes
getNodeList = getNodes
def _isValidNodeName(self, node_name) :
"""Check we have been provided a good node name"""
return isinstance(node_name, str) and NODE_RE.match(node_name)
security.declarePublic('manage_setDistributingNode')
def manage_setDistributingNode(self, distributingNode, REQUEST=None):
""" set the distributing node """
if self._isValidNodeName(distributingNode):
self.distributingNode = distributingNode
if REQUEST is not None:
REQUEST.RESPONSE.redirect(
REQUEST.URL1 +
'/manageLoadBalancing?manage_tabs_message=' +
urllib.quote("Distributing Node successfully changed."))
else :
if REQUEST is not None:
REQUEST.RESPONSE.redirect(
REQUEST.URL1 +
'/manageLoadBalancing?manage_tabs_message=' +
urllib.quote("Malformed Distributing Node."))
security.declarePublic('manage_addNode')
def manage_addNode(self, node, REQUEST=None):
""" add a node """
if not self._isValidNodeName(node) :
if REQUEST is not None:
REQUEST.RESPONSE.redirect(
REQUEST.URL1 +
'/manageLoadBalancing?manage_tabs_message=' +
urllib.quote("Malformed node."))
return
if node in self._nodes:
if REQUEST is not None:
REQUEST.RESPONSE.redirect(
......
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