예제 #1
0
 def getMetaCmd(self, id):
   obs = self.getMetaCmds(sort=False)
   # Filter by id.
   obs = [x for x in obs if x['id'] == id]
   # Not found!
   if len(obs) == 0:
     return None
   # Refresh Object.
   metaCmd = obs[0]
   if metaCmd.get('home',None)==None:
     return None
   if 'exec' in metaCmd:
     metaCmd['execution'] = metaCmd['exec']
     del metaCmd['exec']
   container = self.aq_parent
   src = zopeutil.getObject(metaCmd['home'], metaCmd['id'])
   newData = zopeutil.readObject(metaCmd['home'], metaCmd['id'], '')
   data = zopeutil.readObject(container, metaCmd['id'], '')
   acquiredExternalMethod = metaCmd.get('acquired',0) and src.meta_type=='External Method'
   if src is not None and (newData != data or acquiredExternalMethod):
     newId = metaCmd['id']
     newMethod = src.meta_type
     newTitle = '*** DO NOT DELETE OR MODIFY ***'
     zopeutil.removeObject(container, newId, removeFile=False)
     zopeutil.addObject(container, newMethod, ['',metaCmd['home'].getHome().getId()+'.'][acquiredExternalMethod]+newId, newTitle, newData)
   ob = zopeutil.getObject(container, metaCmd['id'])
   if ob is not None:
     metaCmd['meta_type'] = ob.meta_type
     metaCmd['data'] = zopeutil.readObject(container, metaCmd['id'], '')
     metaCmd['bobobase_modification_time'] = DateTime(ob._p_mtime)
   return metaCmd
예제 #2
0
 def getTransition(self, id, for_export=False):
     transition = [x for x in self.getTransitions() if x['id'] == id][0]
     transition = copy.deepcopy(transition)
     ob = zopeutil.getObject(self, transition['id'])
     if ob is not None:
         transition['ob'] = ob
         transition['type'] = ob.meta_type
     if 'dtml' in transition:
         del transition['dtml']
     return transition
예제 #3
0
 def getFilterProcesses(self, id):
   obs = []
   index = 0
   for process in self.getFilter( id).get( 'processes', []):
     ob = process.copy()
     ob[ 'type'] = ob.get( 'type', 'process')
     prefix = '%s.%i.'%(id,index)
     ids = [x for x in self.objectIds('File') if x.startswith(prefix)]
     if ids:
       f = zopeutil.getObject(self,ids[0])
       ob['file'] = f
       ob['file_href'] = f.absolute_url()
       ob['file_filename'] = '.'.join(f.getId().split('.')[2:])
       ob['file_content_type'] = f.getContentType()
       ob['file_size'] = f.get_size()
     p = self.getProcess(ob['id'])
     if p is not None:
       obs.append( ob)
     index += 1
   return obs
예제 #4
0
 def getProcess(self, id):
   processes = self.processes
   process = {}
   if id in processes:
     process = processes.get( id).copy()
   else:
     # Acquire from parent.
     portalMaster = self.getPortalMaster()
     if portalMaster is not None:
       if id in portalMaster.getFilterManager().getProcessIds():
         process = portalMaster.getFilterManager().getProcess(id)
         process['acquired'] = 1
         return process
   process['id'] = id
   process['name'] = process.get('name',process['id'])
   # Synchronize type.
   ob = zopeutil.getObject( self, process['id'])
   if ob is not None:
     process['ob'] = ob
     process['command'] = zopeutil.readData( ob)
   return process
예제 #5
0
 def getProcess(self, id):
   processes = self.processes
   process = {}
   if id in processes:
     process = processes.get( id).copy()
   else:
     # Acquire from parent.
     portalMaster = self.getPortalMaster()
     if portalMaster is not None:
       if id in portalMaster.getProcessIds():
         process = portalMaster.getProcess(id)
         process['acquired'] = 1
   process['id'] = id
   process['name'] = process.get('name',process['id'])
   # Synchronize type.
   try:
     container = self.getHome()
     ob = zopeutil.getObject( container, process['id'])
     process['command'] = zopeutil.readData( ob)
   except:
     pass
   return process
예제 #6
0
 def provideRepository(self, r, ids=None):
     r = {}
     for id in self.getFilterIds():
         d = self.getFilter(id)
         d['meta_type'] = 'filter'
         d['__icon__'] = 'fas fa-filter'
         d['__description__'] = self.getZMILangStr('ATTR_FILTER')
         d['__filename__'] = ['filters', id, '__init__.py']
         if 'processes' in d:
             del d['processes']
         d['Processes'] = []
         for fp in self.getFilterProcesses(id):
             p = {}
             p['id'] = fp['id']
             if 'file' in fp:
                 p['id'] = '%s/%i.%s' % (fp['id'], len(
                     d['Processes']), fp['file_filename'])
                 p['ob'] = fp['file']
             d['Processes'].append(p)
         r[id] = d
     for id in self.getProcessIds():
         d = self.getProcess(id)
         d['meta_type'] = 'process'
         d['__icon__'] = 'fas fa-cog'
         d['__description__'] = self.getZMILangStr('ATTR_PROCESS')
         d['__filename__'] = ['processes', id, '__init__.py']
         ob = zopeutil.getObject(self, id)
         if ob:
             command = {}
             command['id'] = id
             command['ob'] = ob
             command['type'] = ob.meta_type
             if 'command' in d:
                 del d['command']
             d['Command'] = [command]
         r[id] = d
     return r