def getMergerObject(file_ext): """Returns an instance of the correct merger tool, or None if there is not one""" from Ganga.Utility.Plugin.GangaPlugin import PluginManagerError result = None try: config = getConfig('Mergers') if file_ext == 'std_merge': result = allPlugins.find('postprocessor', config[file_ext])() else: # load the dictionary of file assocaitions # Why was there _ever_ an eval statement here? rcurrie file_types = config['associate'] associate_merger = file_types[file_ext] result = allPlugins.find('postprocessor', associate_merger)() except ConfigError, err: logger.debug("ConfError %s" % str(err))
def start_element(name, attrs): # logger.debug('Start element: name=%s attrs=%s', name, attrs) #FIXME: for 2.4 use CurrentColumnNumber and CurrentLineNumber # if higher level element had error, ignore the corresponding part # of the XML tree as we go down if self.ignore_count: self.ignore_count += 1 return # initialize object stack if name == 'root': assert self.stack is None, "duplicated <root> element" self.stack = [] return assert not self.stack is None, "missing <root> element" # load a class, make empty object and push it as the current object # on the stack if name == 'class': try: cls = allPlugins.find(attrs['category'], attrs['name']) except PluginManagerError as e: self.errors.append(e) #self.errors.append('Unknown class: %(name)s'%attrs) obj = EmptyGangaObject() # ignore all elemenents until the corresponding ending # element (</class>) is reached self.ignore_count = 1 else: version = Version( *[int(v) for v in attrs['version'].split('.')]) if not cls._schema.version.isCompatible(version): attrs['currversion'] = '%s.%s' % ( cls._schema.version.major, cls._schema.version.minor) self.errors.append( SchemaVersionError( 'Incompatible schema of %(name)s, repository is %(version)s currently in use is %(currversion)s' % attrs)) obj = EmptyGangaObject() # ignore all elemenents until the corresponding ending # element (</class>) is reached self.ignore_count = 1 else: # make a new ganga object obj = super(cls, cls).__new__(cls) obj._data = {} self.stack.append(obj) # push the attribute name on the stack if name == 'attribute': self.stack.append(attrs['name']) # start value_contruct mode and initialize the value buffer if name == 'value': self.value_construct = '' # save a marker where the sequence begins on the stack if name == 'sequence': self.sequence_start.append(len(self.stack))
def start_element(name, attrs): #logger.debug('Start element: name=%s attrs=%s', name, attrs) #FIXME: for 2.4 use CurrentColumnNumber and CurrentLineNumber # if higher level element had error, ignore the corresponding part # of the XML tree as we go down if self.ignore_count: self.ignore_count += 1 return # initialize object stack if name == 'root': assert self.stack is None, "duplicated <root> element" self.stack = [] return assert not self.stack is None, "missing <root> element" # load a class, make empty object and push it as the current object # on the stack if name == 'class': try: cls = allPlugins.find(attrs['category'], attrs['name']) except PluginManagerError as e: self.errors.append(e) #self.errors.append('Unknown class: %(name)s'%attrs) obj = EmptyGangaObject() # ignore all elemenents until the corresponding ending # element (</class>) is reached self.ignore_count = 1 else: version = Version( *[int(v) for v in attrs['version'].split('.')]) if not cls._schema.version.isCompatible(version): attrs['currversion'] = '%s.%s' % ( cls._schema.version.major, cls._schema.version.minor) self.errors.append( SchemaVersionError( 'Incompatible schema of %(name)s, repository is %(version)s currently in use is %(currversion)s' % attrs)) obj = EmptyGangaObject() # ignore all elemenents until the corresponding ending # element (</class>) is reached self.ignore_count = 1 else: # make a new ganga object obj = cls() self.stack.append(obj) # push the attribute name on the stack if name == 'attribute': self.stack.append(attrs['name']) # start value_contruct mode and initialize the value buffer if name == 'value': self.value_construct = '' # save a marker where the sequence begins on the stack if name == 'sequence': self.sequence_start.append(len(self.stack))
def string_type_shortcut_filter(val,item): if type(val) is type(''): if item is None: raise ValueError('cannot apply default string conversion, probably you are trying to use it in the constructor') from Ganga.Utility.Plugin import allPlugins, PluginManagerError try: obj = allPlugins.find(item['category'],val)() obj._auto__init__() return obj except PluginManagerError,x: raise ValueError(x)
def _make_empty_object_(self, id, category, classname): """Internal helper: adds an empty GangaObject of the given class to the repository. Raise RepositoryError Raise PluginManagerError if the class name is not found""" cls = allPlugins.find(category, classname) obj = super(cls, cls).__new__(cls) obj._proxyObject = None obj._data = None self._internal_setitem__(id,obj) return obj
def string_type_shortcut_filter(val, item): if isinstance(val, type('')): if item is None: raise ValueError('cannot apply default string conversion, probably you are trying to use it in the constructor') from Ganga.Utility.Plugin import allPlugins, PluginManagerError try: obj = allPlugins.find(item['category'], val)() obj._auto__init__() return obj except PluginManagerError as err: logger.debug("string_type_shortcut_filter Exception: %s" % str(err)) raise ValueError(err) return None
def _getDefaultValueInternal(self, attr, val=None, check=False): """ Get the default value of a schema item, both simple and component. If check is True then val is used instead of default value: this is used to check if the val may be used as a default value (e.g. if it is OK to use it as a value in the config file) """ def_name = defaultConfigSectionName(self.name) item = self.getItem(attr) stored_attr_key = def_name + ':' + str(attr) from Ganga.Utility.Config import Config from Ganga.Utility.Config import getConfig is_finalized = Config._after_bootstrap if is_finalized and stored_attr_key in _found_attrs.keys(): defvalue = _found_attrs[stored_attr_key] else: config = Ganga.Utility.Config.getConfig(def_name) # hidden, protected and sequence values are not represented in config if attr in config: defvalue = config[attr] else: defvalue = item['defvalue'] _found_attrs[stored_attr_key] = defvalue # in the checking mode, use the provided value instead if check: defvalue = val if item.isA(ComponentItem): # FIXME: limited support for initializing non-empty sequences (i.e. # apps => ['DaVinci','Executable'] is NOT correctly initialized) if not item['sequence']: if defvalue is None: if not item['load_default']: assert(item['optional']) return None # if a defvalue of a component item is an object (not string) just process it as for SimpleItems (useful for FileItems) # otherwise do a lookup via plugin registry if isinstance(defvalue, str) or defvalue is None: return allPlugins.find(item['category'], defvalue)() # make a copy of the default value (to avoid strange effects if the # original modified) return copy.deepcopy(defvalue)
def getMergerObject(file_ext): """Returns an instance of the correct merger tool, or None if there is not one""" from Ganga.Utility.Plugin.GangaPlugin import PluginManagerError result = None try: config = getConfig('Mergers') if file_ext == 'std_merge': result = allPlugins.find('mergers',config[file_ext])() else: #load the dictionary of file assocaitions file_types = eval(config['associate']) result = allPlugins.find('mergers',file_types[file_ext])() except ConfigError: pass except KeyError: pass except PluginManagerError: pass except SyntaxError: pass except TypeError:#TypeError as we may not be able to call () pass #just return None return result
def _make_empty_object_(self, this_id, category, classname): """Internal helper: adds an empty GangaObject of the given class to the repository. Raise RepositoryError Raise PluginManagerError if the class name is not found""" if (category, classname) not in self._found_classes: cls = allPlugins.find(category, classname) self._found_classes[(category, classname)] = cls cls = self._found_classes[(category, classname)] obj = super(cls, cls).__new__(cls) obj.__init__() obj._proxyObject = None obj.setNodeData({}) self._internal_setitem__(this_id, obj) return obj
def gangaObjectFactory(attrDict, migration_class=None): ## gangaObjectFactory(...) --> (object, migrated, [<list of errors>]) migrated = [False] errors = [] if attrDict["simple"]: return (None, migrated[0], errors) if migration_class: cls = migration_class else: try: cls = allPlugins.find(attrDict["category"], attrDict["name"]) except PluginManagerError, e: msg = "Plugin Manager Error: %s" % str(e) errors.append(GangaObjectFactoryError(e, msg=msg)) return (EmptyGangaObject(), migrated[0], errors)
def _make_empty_object_(self, this_id, category, classname): """Internal helper: adds an empty GangaObject of the given class to the repository. Raise RepositoryError Raise PluginManagerError if the class name is not found""" compound_name = str(category+"_"+classname) if compound_name not in self._found_classes: cls = allPlugins.find(category, classname) self._found_classes[compound_name] = cls cls = self._found_classes[compound_name] obj = cls() obj._data = {} obj._setFlushed() self._internal_setitem__(this_id, obj) return obj
def _make_empty_object_(self, this_id, category, classname): """Internal helper: adds an empty GangaObject of the given class to the repository. Raise RepositoryError Raise PluginManagerError if the class name is not found""" compound_name = str(category+"_"+classname) if compound_name not in self._found_classes: cls = allPlugins.find(category, classname) self._found_classes[compound_name] = cls cls = self._found_classes[compound_name] obj = cls() #setattr(obj, '_parent', None) #obj.__init__() obj.setNodeData({}) obj.setNodeAttribute('id', this_id) self._internal_setitem__(this_id, obj) return obj
def _make_empty_object_(self, this_id, category, classname): """Internal helper: adds an empty GangaObject of the given class to the repository. Raise RepositoryError Raise PluginManagerError if the class name is not found""" compound_name = str(category + "_" + classname) if compound_name not in self._found_classes: cls = allPlugins.find(category, classname) self._found_classes[compound_name] = cls cls = self._found_classes[compound_name] obj = cls() #setattr(obj, '_parent', None) #obj.__init__() obj.setNodeData({}) obj.setNodeAttribute('id', this_id) self._internal_setitem__(this_id, obj) return obj
def autoPopulateGPI(my_interface=None): """ Fully expose all plugins registered with the interface in a single line. By default only populate GPI, but also populate any other interface requested """ if not my_interface: import Ganga.GPI my_interface = Ganga.GPI from Ganga.Runtime.GPIexport import exportToInterface from Ganga.Utility.Plugin import allPlugins # make all plugins visible in GPI for k in allPlugins.allCategories(): for n in allPlugins.allClasses(k): cls = allPlugins.find(k, n) if not cls._declared_property('hidden'): if n != cls.__name__: exportToInterface(my_interface, cls.__name__, cls, 'Classes') exportToInterface(my_interface, n, cls, 'Classes')
def _make_empty_object_(self, this_id, category, classname): """Internal helper: adds an empty GangaObject of the given class to the repository. Raise RepositoryError Raise PluginManagerError if the class name is not found Args: this_id (int): This is the id to assign to the empty object category (str): This is the category the object belongs to classname (str): This is the name of the class of the object which is used to construct it """ compound_name = str(category+"_"+classname) if compound_name not in self._found_classes: cls = allPlugins.find(category, classname) self._found_classes[compound_name] = cls cls = self._found_classes[compound_name] obj = cls() obj._data = {} obj._setFlushed() self._internal_setitem__(this_id, obj) return obj
def _make_empty_object_(self, this_id, category, classname): """Internal helper: adds an empty GangaObject of the given class to the repository. Raise RepositoryError Raise PluginManagerError if the class name is not found Args: this_id (int): This is the id to assign to the empty object category (str): This is the category the object belongs to classname (str): This is the name of the class of the object which is used to construct it """ compound_name = str(category + "_" + classname) if compound_name not in self._found_classes: cls = allPlugins.find(category, classname) self._found_classes[compound_name] = cls cls = self._found_classes[compound_name] obj = cls() obj._data = {} obj._setFlushed() self._internal_setitem__(this_id, obj) return obj
def _getDefaultValueInternal(self, attr, val=None, check=False): """ Get the default value of a schema item, both simple and component. If check is True then val is used instead of default value: this is used to check if the val may be used as a default value (e.g. if it is OK to use it as a value in the config file) """ def_name = defaultConfigSectionName(self.name) item = self.getItem(attr) stored_attr_key = def_name + ':' + str(attr) from Ganga.Utility.Config import Config is_finalized = Config._after_bootstrap useDefVal = False try: # Attempt to get the relevant config section config = Config.getConfig(def_name) if is_finalized and stored_attr_key in _found_attrs and not config.hasModified: defvalue = _found_attrs[stored_attr_key] else: if attr in config.getEffectiveOptions(): defvalue = config[attr] from Ganga.GPIDev.Base.Proxy import isProxy if isProxy(defvalue): raise GangaException("(1)Proxy found where it shouldn't be in the Config: %s" % stored_attr_key) ## Just in case a developer puts the proxied object into the default value! _found_attrs[stored_attr_key] = defvalue else: useDefVal = True except (KeyError, Config.ConfigError): useDefVal = True if useDefVal: # hidden, protected and sequence values are not represented in config defvalue = item['defvalue'] from Ganga.GPIDev.Base.Proxy import isProxy if isProxy(defvalue): raise GangaException("(2)Proxy found where is shouldn't be in the Config" % stored_attr_key) ## Just in case a developer puts the proxied object into the default value! _found_attrs[stored_attr_key] = defvalue # in the checking mode, use the provided value instead if check is True: defvalue = val if isinstance(item, ComponentItem): # FIXME: limited support for initializing non-empty sequences (i.e. # apps => ['DaVinci','Executable'] is NOT correctly initialized) if not item['sequence']: if defvalue is None: if not item['load_default']: assert(item['optional']) return None # if a defvalue of a component item is an object (not string) just process it as for SimpleItems (useful for FileItems) # otherwise do a lookup via plugin registry category = item['category'] if isinstance(defvalue, str) or defvalue is None: try: config = Config.getConfig(def_name) has_modified = config.hasModified except KeyError: has_modified = False if category not in _found_components or has_modified: _found_components[category] = allPlugins.find(category, defvalue) return _found_components[category]() # If needed/requested make a copy of the function elsewhwre return defvalue
logger.error('problems with loading Named Templates for %s', n) logger.error('Reason: %s' % str(err)) for r in allRuntimes.values(): try: r.loadPlugins() except Exception as err: logger.error("problems with loading plugins for %s -- ignored" % r.name) logger.error('Reason: %s' % str(err)) # ------------------------------------------------------------------------------------ # make all plugins visible in GPI for k in allPlugins.allCategories(): for n in allPlugins.allClasses(k): cls = allPlugins.find(k, n) if not cls._declared_property('hidden'): exportToPublicInterface(n, cls._proxyClass, 'Classes') # ------------------------------------------------------------------------------------ # set the default value for the plugins default_plugins_cfg = getConfig("Plugins") for opt in default_plugins_cfg: try: category, tag = opt.split('_') except ValueError, err: logger.warning("do not understand option %s in [Plugins]", opt) logger.debug('Reason: want %s' % str(err)) else: if tag == 'default':
def _getDefaultValueInternal(self, attr, val=None, check=False): """ Get the default value of a schema item, both simple and component. If check is True then val is used instead of default value: this is used to check if the val may be used as a default value (e.g. if it is OK to use it as a value in the config file) """ def_name = defaultConfigSectionName(self.name) item = self.getItem(attr) stored_option_key = def_name stored_attr_key = def_name + ':' + attr is_finalized = Config._after_bootstrap useDefVal = False try: # Attempt to get the relevant config section if is_finalized: if stored_option_key in _stored_configs: config = _stored_configs[stored_option_key] else: config = Config.getConfig(def_name) _stored_configs[stored_option_key] = config else: config = Config.getConfig(def_name) if is_finalized and not config.hasModified and stored_attr_key in _found_attrs: defvalue = _found_attrs[stored_attr_key] else: if is_finalized: if stored_option_key in _stored_options and not config.hasModified: eff_ops = _stored_options[stored_option_key] else: eff_ops = config.getEffectiveOptions() _stored_options[stored_option_key] = eff_ops else: eff_ops = config.getEffectiveOptions() if attr in eff_ops: defvalue = config[attr] from Ganga.GPIDev.Base.Proxy import isProxy if isProxy(defvalue): raise GangaException("(1)Proxy found where it shouldn't be in the Config: %s" % stored_attr_key) ## Just in case a developer puts the proxied object into the default value! _found_attrs[stored_attr_key] = defvalue else: useDefVal = True except (KeyError, Config.ConfigError): useDefVal = True if useDefVal: # hidden, protected and sequence values are not represented in config defvalue = item['defvalue'] from Ganga.GPIDev.Base.Proxy import isProxy if isProxy(defvalue): raise GangaException("(2)Proxy found where is shouldn't be in the Config" % stored_attr_key) ## Just in case a developer puts the proxied object into the default value! _found_attrs[stored_attr_key] = defvalue # in the checking mode, use the provided value instead if check is True: defvalue = val if isinstance(item, ComponentItem): # FIXME: limited support for initializing non-empty sequences (i.e. # apps => ['DaVinci','Executable'] is NOT correctly initialized) if not item['sequence']: if defvalue is None: if not item['load_default']: try: assert(item['optional']) except AssertionError: raise SchemaError("This item '%s' is not a sequence, doesn't have a load_default and is not optional. This is unsupported!" % type(item)) return None # if a defvalue of a component item is an object (not string) just process it as for SimpleItems (useful for FileItems) # otherwise do a lookup via plugin registry category = item['category'] if isinstance(defvalue, str) or defvalue is None: try: config = Config.getConfig(def_name) has_modified = config.hasModified except KeyError: has_modified = False if category not in _found_components or has_modified: _found_components[category] = allPlugins.find(category, defvalue) return _found_components[category]() if isclass(defvalue): return defvalue() # If needed/requested make a copy of the function elsewhwre return defvalue
except Exception as err: logger.error('problems with loading Named Templates for %s', n) logger.error('Reason: %s' % str(err)) for r in allRuntimes.values(): try: r.loadPlugins() except Exception as err: logger.error("problems with loading plugins for %s -- ignored" % r.name) logger.error('Reason: %s' % str(err)) # ------------------------------------------------------------------------------------ # make all plugins visible in GPI for k in allPlugins.allCategories(): for n in allPlugins.allClasses(k): cls = allPlugins.find(k, n) if not cls._declared_property('hidden'): exportToPublicInterface(n, getProxyClass(cls), 'Classes') # ------------------------------------------------------------------------------------ # set the default value for the plugins default_plugins_cfg = getConfig("Plugins") for opt in default_plugins_cfg: try: category, tag = opt.split('_') except ValueError, err: logger.warning("do not understand option %s in [Plugins]", opt) logger.debug('Reason: want %s' % str(err)) else: if tag == 'default':
def _getDefaultValueInternal(self, attr, val=None, check=False): """ Get the default value of a schema item, both simple and component. If check is True then val is used instead of default value: this is used to check if the val may be used as a default value (e.g. if it is OK to use it as a value in the config file) """ def_name = defaultConfigSectionName(self.name) item = self.getItem(attr) stored_attr_key = def_name + ':' + str(attr) from Ganga.Utility.Config import Config is_finalized = Config._after_bootstrap useDefVal = False try: # Attempt to get the relevant config section config = Config.getConfig(def_name, create=False) if is_finalized and stored_attr_key in _found_attrs and not config.hasModified(): defvalue = _found_attrs[stored_attr_key] else: if attr in config.getEffectiveOptions(): defvalue = config[attr] from Ganga.GPIDev.Base.Proxy import isProxy if isProxy(defvalue): raise GangaException("(1)Proxy found where it shouldn't be in the Config: %s" % stored_attr_key) ## Just in case a developer puts the proxied object into the default value! _found_attrs[stored_attr_key] = defvalue else: useDefVal = True except (KeyError, Config.ConfigError): useDefVal = True if useDefVal: # hidden, protected and sequence values are not represented in config defvalue = item['defvalue'] from Ganga.GPIDev.Base.Proxy import isProxy if isProxy(defvalue): raise GangaException("(2)Proxy found where is shouldn't be in the Config" % stored_attr_key) ## Just in case a developer puts the proxied object into the default value! _found_attrs[stored_attr_key] = defvalue # in the checking mode, use the provided value instead if check is True: defvalue = val if isinstance(item, ComponentItem): # FIXME: limited support for initializing non-empty sequences (i.e. # apps => ['DaVinci','Executable'] is NOT correctly initialized) if not item['sequence']: if defvalue is None: if not item['load_default']: assert(item['optional']) return None # if a defvalue of a component item is an object (not string) just process it as for SimpleItems (useful for FileItems) # otherwise do a lookup via plugin registry category = item['category'] if isinstance(defvalue, str) or defvalue is None: try: config = Config.getConfig(def_name, create=False) has_modified = config.hasModified() except KeyError: has_modified = False if category not in _found_components or has_modified: _found_components[category] = allPlugins.find(category, defvalue) return _found_components[category]() # make a copy of the default value (to avoid strange effects if the # original modified) try: from Ganga.GPIDev.Base.Proxy import isType, getRuntimeGPIObject, stripProxy, getName from Ganga.GPIDev.Base.Objects import Node if isinstance(defvalue, Node): return stripProxy(getRuntimeGPIObject(getName(defvalue))) else: return copy.deepcopy(defvalue) except ImportError: return copy.deepcopy(defvalue)
logger.warning("do not understand option %s in [Plugins]", opt) logger.debug('Reason: want %s' % str(err)) else: if tag == 'default': try: allPlugins.setDefault(category, default_plugins_cfg[opt]) except Ganga.Utility.Plugin.PluginManagerError as x: logger.warning('cannot set the default plugin "%s": %s' % (opt, x)) else: logger.warning("do not understand option %s in [Plugins]", opt) # set alias for default Batch plugin (it will not appear in the # configuration) batch_default_name = getConfig('Configuration').getEffectiveOption('Batch') try: batch_default = allPlugins.find('backends', batch_default_name) except Exception as x: raise Ganga.Utility.Config.ConfigError('Check configuration. Unable to set default Batch backend alias (%s)' % str(x)) else: allPlugins.add(batch_default, 'backends', 'Batch') from Ganga.Runtime.GPIexport import exportToInterface if not my_interface: import Ganga.GPI my_interface = Ganga.GPI exportToInterface(my_interface, 'Batch', batch_default, 'Classes')
def gangaObjectFactory(attrDict, migration_class=None): # gangaObjectFactory(...) --> (object, migrated, [<list of errors>]) migrated = [False] errors = [] if attrDict['simple']: return (None, migrated[0], errors) if migration_class: cls = migration_class else: try: cls = allPlugins.find(attrDict['category'], attrDict['name']) except PluginManagerError as e: msg = "Plugin Manager Error: %s" % str(e) errors.append(GangaObjectFactoryError(e, msg=msg)) return (EmptyGangaObject(), migrated[0], errors) schema = cls._schema major, minor = attrDict['version'] version = Version(major, minor) if not schema.version.isCompatible(version): v1 = '.'.join(map(str, [major, minor])) v2 = '.'.join(map(str, [schema.version.major, schema.version.minor])) msg = "Incompatible schema versions of plugin %s in the category %s. Current version %s. Repository version %s." % ( attrDict['name'], attrDict['category'], v2, v1) if schema.version.major > version.major: # no forward migration from .MigrationControl import migration if migration.isAllowed(attrDict['category'], attrDict['name'], attrDict['version'], msg=msg): # try if migration provided by the plugin class try: old_cls = cls.getMigrationClass(version) except: old_cls = None if old_cls: old_obj, old_migrated, old_errors = gangaObjectFactory( attrDict, migration_class=old_cls) if old_migrated: migrated[0] = old_migrated if not old_errors: try: obj = cls.getMigrationObject(old_obj) #assert(isinstance(obj, cls)) except Exception as e: msg += ' Error in object migration: ' + str(e) else: obj.__setstate__(obj.__dict__) migrated[0] = True return (obj, migrated[0], errors) else: msg += ' Errors in object migration ' + \ str(map(str, old_errors)) else: msg += ' No migration class is provided.' else: msg += ' Migration was denied in the migration control object.' errors.append(GangaObjectFactoryError(msg=msg)) return (EmptyGangaObject(), migrated[0], errors) obj = super(cls, cls).__new__(cls) obj._data = {} def mapper(attrDict): if attrDict['simple']: val = attrDict['data'] else: val, attr_migrated, attr_errors = gangaObjectFactory(attrDict) if attr_migrated: migrated[0] = attr_migrated for err in attr_errors: if str(err) not in map(str, errors): # don't duplicate the same errors errors.append(err) return val data = attrDict['data'] for attr, item in schema.allItems(): if attr in data: val = data[attr] if item['sequence']: val = makeGangaList(val, mapper, parent=obj) else: val = mapper(val) else: val = schema.getDefaultValue(attr) obj._data[attr] = val obj.__setstate__(obj.__dict__) return (obj, migrated[0], errors)
if item.isA(ComponentItem): # FIXME: limited support for initializing non-empty sequences (i.e. apps => ['DaVinci','Executable'] is NOT correctly initialized) if not item['sequence']: if defvalue is None: if not item['load_default']: assert(item['optional']) return None # if a defvalue of a component item is an object (not string) just process it as for SimpleItems (useful for FileItems) # otherwise do a lookup via plugin registry if type(defvalue) is type('') or defvalue is None: from Ganga.Utility.Plugin import allPlugins return allPlugins.find(item['category'],defvalue)() # make a copy of the default value (to avoid strange effects if the original modified) import copy return copy.deepcopy(defvalue) # Items in schema may be either Components,Simples, Files or BindingItems. # # Component, Simple, File are data items and have implicit storage. # # Metaproperties of all Items: # # transient : never stored on persistent media # protected : not modifiable via GPI