Пример #1
0
 def createnode(self, node, data):
     if IScheduleHolderParent.providedBy(node):
         defaultname = "Holder %d"
         nodetype = ScheduleHolder
     elif IScheduleHolder.providedBy(node):
         defaultname = "RZShed_%d"
         nodetype = Schedule
     else:
         message = "createnode() does not know what to create for %s"
         raise TypeError(message % node)
     parentnode = node
     if data.has_key("configure.name"):
         childname = urllib.unquote_plus(data['configure.name'][0])
     else:
         index = len(parentnode.children_nodes()) + 1
         childname = defaultname % index
         while parentnode.has_child(childname):
             index += 1
             childname = defaultname % index
         childname = defaultname % len(parentnode.children_nodes())
     if not childname:
         raise TypeError("Illegal node name: %r" % childname)
     if IScheduleHolder.providedBy(node):
         if childname == '':
             error = "Holder name required"
             raise TypeError(error)
         if not childname.startswith("RZSched_"):
             if childname.lower().startswith("rzsched_"):
                 childname = childname.lower().split("rzsched_")[1]
             childname = "RZSched_" + childname
     config = {
         'name': childname,
         'parent': parentnode,
         'description': '',
         'source': 'ScheduleConfigurator'
     }
     message = "createnode() creating %s type child of %s."
     self.message(message, nodetype.__name__, parentnode)
     childnode = nodetype()
     childnode.configure(config)
     return parentnode
Пример #2
0
 def updatepdo(self, managernode):
     self.debugout("updatepdo(%s)", as_node_url(managernode))
     tstart = time.time()
     while not IScheduleHolderParent.providedBy(managernode):
         managernode = managernode.parent
     managername = managernode.name
     self.message('updating PDO for %s.', as_node_url(managernode))
     self._pdo_lock.acquire()
     try:
         holderdict = self._pdo.holders.setdefault(managername, {})
         holderdict.clear()
         scheduledicts = self._pdo.schedules.setdefault(managername, {})
         scheduledicts.clear()
         children = managernode.children_nodes()
         holders = filter(IScheduleHolder.providedBy, children)
         for holder in holders:
             if holder.source == 'ScheduleConfigurator':
                 self.debugout('storing holder %s.', as_node_url(holder))
                 holderdict[holder.name] = cPickle.dumps(IPickles(holder))
             else:
                 self.debugout('skipping holder %s.', as_node_url(holder))
             scheduledict = scheduledicts.setdefault(holder.name, {})
             scheduledict.clear()
             schedules = filter(ISchedule.providedBy,
                                holder.children_nodes())
             for schedule in schedules:
                 if schedule.source == 'ScheduleConfigurator':
                     self.debugout('storing schedule %s.',
                                   as_node_url(schedule))
                     scheduledata = cPickle.dumps(IPickles(schedule))
                     scheduledict[schedule.name] = scheduledata
                 else:
                     self.debugout('skipping schedule %s.',
                                   as_node_url(schedule))
         self._pdo.save()
     finally:
         self._pdo_lock.release()
     tend = time.time()
     self.debugout('took %0.3f secs to update PDO.', tend - tstart)
Пример #3
0
 def updatepdo(self, managernode):
     self.debugout("updatepdo(%s)", as_node_url(managernode))
     tstart = time.time()
     while not IScheduleHolderParent.providedBy(managernode):
         managernode = managernode.parent
     managername = managernode.name
     self.message('updating PDO for %s.', as_node_url(managernode))
     self._pdo_lock.acquire()
     try: 
         holderdict = self._pdo.holders.setdefault(managername, {})
         holderdict.clear()
         scheduledicts = self._pdo.schedules.setdefault(managername,{})
         scheduledicts.clear()
         children = managernode.children_nodes()
         holders = filter(IScheduleHolder.providedBy, children)
         for holder in holders:
             if holder.source == 'ScheduleConfigurator':
                 self.debugout('storing holder %s.', as_node_url(holder))
                 holderdict[holder.name] = cPickle.dumps(IPickles(holder))
             else:
                 self.debugout('skipping holder %s.', as_node_url(holder))
             scheduledict = scheduledicts.setdefault(holder.name, {})
             scheduledict.clear()
             schedules = filter(ISchedule.providedBy, 
                                holder.children_nodes())
             for schedule in schedules:
                 if schedule.source == 'ScheduleConfigurator':
                     self.debugout(
                         'storing schedule %s.', as_node_url(schedule))
                     scheduledata = cPickle.dumps(IPickles(schedule))
                     scheduledict[schedule.name] = scheduledata
                 else:
                     self.debugout(
                         'skipping schedule %s.', as_node_url(schedule))
         self._pdo.save()
     finally: 
         self._pdo_lock.release()
     tend = time.time()
     self.debugout('took %0.3f secs to update PDO.', tend - tstart)         
Пример #4
0
 def createnode(self, node, data):
     if IScheduleHolderParent.providedBy(node):
         defaultname = "Holder %d"
         nodetype = ScheduleHolder
     elif IScheduleHolder.providedBy(node):
         defaultname = "RZShed_%d"
         nodetype = Schedule
     else:
         message = "createnode() does not know what to create for %s"
         raise TypeError(message % node)
     parentnode = node
     if data.has_key("configure.name"):
         childname = urllib.unquote_plus(data['configure.name'][0])
     else:
         index = len(parentnode.children_nodes()) + 1
         childname = defaultname % index
         while parentnode.has_child(childname):
             index += 1
             childname = defaultname % index
         childname = defaultname % len(parentnode.children_nodes())
     if not childname:
         raise TypeError("Illegal node name: %r" % childname)
     if IScheduleHolder.providedBy(node):
         if childname == '':
             error = "Holder name required"
             raise TypeError(error)
         if not childname.startswith("RZSched_"):
             if childname.lower().startswith("rzsched_"):
                 childname = childname.lower().split("rzsched_")[1]
             childname = "RZSched_" + childname                
     config = {'name': childname, 'parent': parentnode,
                'description': '', 'source': 'ScheduleConfigurator'}
     message = "createnode() creating %s type child of %s."
     self.message(message, nodetype.__name__, parentnode)
     childnode = nodetype()
     childnode.configure(config)
     return parentnode