def IsTypeAllowed(self, type, user=None): """ Check if *type* is allowed to be created in this container based on configuration.subtypes.:: type = the type to be checked user = the currently active user returns True/False *type* can be passed as - type id string - configuration object - type object instance """ if type is None: return False subtypes = self.configuration.subtypes if subtypes == AllTypesAllowed: return True if not subtypes: return False if isinstance(type, basestring): if type in subtypes: return True # dotted python to obj configuration type = self.app.GetObjectConf(type) if type is None: return False # create type from configuration type = self._GetVirtualObj(type) if type is None: return False if isinstance(type, baseConf): if type.id in subtypes: return True # create type from configuration type = self._GetVirtualObj(type) if type is None: return False if not IObject.providedBy(type) and not IConf.providedBy(type): return False # loop subtypes for iface in subtypes: if isinstance(iface, basestring): iface = ResolveName(iface, raiseExcp=False) if not iface: continue try: # may not be interface class if iface.providedBy(type): return True except: pass return False
def GetApps(self, interface=None): """ Returns registered components and apps as list. """ if isinstance(interface, basestring): interface = ResolveName(interface) apps = [] for name in self.components: a = getattr(self, name) if interface: if not interface.providedBy(a): continue apps.append(a) return apps
def GetApps(self, interface=None): """ Returns registered components and apps as list. """ if isinstance(interface, basestring): interface = ResolveName(interface) apps=[] for name in self.components: a = getattr(self, name) if interface: if not interface.providedBy(a): continue apps.append(a) return apps
def GetAllowedTypes(self, user=None, visible=1): """ List types allowed to be created in this container based on configuration.subtypes. :: user = the currently active user visible = will skip all hidden object types returns list of configurations """ subtypes = self.configuration.subtypes if not subtypes: return False all = self.app.GetAllObjectConfs(visibleOnly=visible) if subtypes == AllTypesAllowed: return all # check types by interface allowed = [] for conf in all: # create type from configuration type = self._GetVirtualObj(conf) if not type: continue # loop subtypes for iface in subtypes: if isinstance(iface, basestring): iface = ResolveName(iface, raiseExcp=False) if not iface: continue try: # may not be interface class if iface.providedBy(type): allowed.append(conf) except: pass return allowed