--- a/configurationengine/source/cone/public/api.py Tue Oct 26 10:43:50 2010 +0100
+++ b/configurationengine/source/cone/public/api.py Sat Nov 06 16:59:14 2010 +0200
@@ -614,12 +614,44 @@
for child in configuration._traverse(type=Configuration):
export_storage.unload(child.get_full_path(),child)
+ ruleml_eval_globals_files = []
+ for child in configuration._traverse(type=RulemlEvalGlobals):
+ if child.file != None:
+ ruleml_eval_globals_files.append(RulemlEvalGlobals.get_script_file_full_path(child))
+
#If the configuration is not in the root of the project adding the path
#to final exporting source path.
#l = []
+ empty_folders = kwargs.get('empty_folders',False)
+ layer = configuration.get_layer()
+ all_resources = []
+ layer_content = layer.list_content(empty_folders)
+ layer_doc = layer.list_doc(empty_folders)
+ layer_implml = layer.list_implml(empty_folders)
+
+ include_filters = kwargs.get('include_filters',{})
+ exclude_filters = kwargs.get('exclude_filters',{})
+
+ include_content_filter = include_filters.get('content')
+ exclude_content_filter = exclude_filters.get('content')
+
+ # perform filtering of content files
+ if exclude_content_filter:
+ f = lambda x: not re.search(exclude_content_filter, x, re.IGNORECASE)
+ layer_content = filter(f,layer_content)
+
+ if include_content_filter:
+ f = lambda x: re.search(include_content_filter, x, re.IGNORECASE)
+ layer_content = filter(f,layer_content)
+
+ all_resources.extend(layer_content)
+ all_resources.extend(layer_doc)
+ all_resources.extend(layer_implml)
+
cpath = utils.resourceref.get_path(configuration.get_path())
resr = [utils.resourceref.join_refs([cpath,related]) \
- for related in configuration.get_layer().list_all_related(**kwargs)]
+ for related in all_resources]
+ resr.extend(ruleml_eval_globals_files)
self.storage.export_resources(resr ,export_storage, kwargs.get("empty_folders", False))
return
@@ -909,16 +941,14 @@
super(Configuration, self).__init__(utils.resourceref.to_objref(self.path), **kwargs)
self.container = True
- def __reduce_ex__(self, protocol_version):
- """
- Make the Configuration pickle a ConfigurationProxy object that would load this configuration
- """
- proxy = ConfigurationProxy(self.path, store_interface = self.get_project())
- tpl = proxy.__reduce_ex__(protocol_version)
- return tpl
-
def __getstate__(self):
- return None
+ state = self.__dict__.copy()
+ if state.has_key('_children'):
+ childs = state.get('_children')
+ if childs.has_key('?default_view'):
+ childs.pop('?default_view')
+ state['_children'] = childs
+ return state
def _default_object(self, name):
return self._default_class()(name)
@@ -1376,12 +1406,6 @@
"""
super(ConfigurationProxy,self).__init__(path, **kwargs)
self.set('_name', utils.resourceref.to_objref(path))
-
- def __reduce_ex__(self, protocol_version):
- """
- Make the Configuration pickle a ConfigurationProxy object that would load this configuration
- """
- return super(ConfigurationProxy, self).__reduce_ex__(protocol_version)
def _clone(self, **kwargs):
"""
@@ -1662,6 +1686,7 @@
self.relevant = kwargs.get('relevant', None)
self.constraint = kwargs.get('constraint', None)
self._dataproxy = None
+ self.extensionAttributes = []
def __copy__(self):
dict = {}
@@ -1677,6 +1702,11 @@
state = super(Feature, self).__getstate__()
# remove the dataproxy value so that it is not stored in serializings
state.pop('_dataproxy', None)
+ # remove instancemethods so that those are not stored in serializings
+ state.pop('get_original_value', None)
+ state.pop('get_value', None)
+ state.pop('set_value', None)
+ state.pop('add_feature', None)
return state
def __setstate__(self, state):
@@ -2197,6 +2227,14 @@
else: value_list = value_subsetting.get_original_value()
return value_list[key_list.index(mapping_key)]
+ def set_extension_attributes(self, attributes):
+ self.extensionAttributes = attributes
+
+ def get_extension_attributes(self):
+ return self.extensionAttributes
+
+ def add_extension_attribute(self, attribute):
+ self.extensionAttributes.append(attribute)
class FeatureSequence(Feature):
POLICY_REPLACE = 0
@@ -2625,11 +2663,6 @@
self.type = 'subseq'
self._index = 0
- def __getstate__(self):
- state = super(FeatureSequenceSub,self).__getstate__()
- state['_children'].pop('?datarows', None)
- return state
-
def get_index(self):
"""
@return : the index of the data element for sequential data defined inside the same configuration.
@@ -3291,6 +3324,7 @@
self.relevant = kwargs.get('relevant', None)
self.map_value = kwargs.get('map_value', None)
self.display_name = kwargs.get('display_name', None)
+ self.extensionAttributes = []
@classmethod
def to_optref(cls, value, map):
@@ -3323,6 +3357,14 @@
else:
return 1
+ def set_extension_attributes(self, attributes):
+ self.extensionAttributes = attributes
+
+ def get_extension_attributes(self):
+ return self.extensionAttributes
+
+ def add_extension_attribute(self, attribute):
+ self.extensionAttributes.append(attribute)
class Storage(object):
"""
@@ -3345,13 +3387,6 @@
self.__opened_res__ = {}
self.mode = mode
self.cpath_stack = []
-
- def __reduce_ex__(self, protocol_version):
- return (open_storage,
- (self.path, self.mode),
- None,
- None,
- None)
def __opened__(self, res):
"""
@@ -3974,33 +4009,33 @@
lres.append(utils.resourceref.join_refs([layerpath, respath]))
return lres
- def list_implml(self):
+ def list_implml(self,empty_folders=False):
"""
@return: array of implml file references.
"""
lres = []
for layerpath in self.list_layers():
- for respath in self.get_layer(layerpath).list_implml():
+ for respath in self.get_layer(layerpath).list_implml(empty_folders):
lres.append(utils.resourceref.join_refs([layerpath, respath]))
return lres
- def list_content(self):
+ def list_content(self,empty_folders=False):
"""
@return: array of content file references.
"""
lres = []
for layerpath in self.list_layers():
- for respath in self.get_layer(layerpath).list_content():
+ for respath in self.get_layer(layerpath).list_content(empty_folders):
lres.append(utils.resourceref.join_refs([layerpath, respath]))
return lres
- def list_doc(self):
+ def list_doc(self,empty_folders=False):
"""
@return: array of document file references.
"""
lres = []
for layerpath in self.list_layers():
- for respath in self.get_layer(layerpath).list_doc():
+ for respath in self.get_layer(layerpath).list_doc(empty_folders):
lres.append(utils.resourceref.join_refs([layerpath, respath]))
return lres
@@ -4080,28 +4115,28 @@
res += super(Layer, self).list_confml()
return res
- def list_implml(self):
+ def list_implml(self,empty_folders=False):
"""
@return: array of implml file references.
"""
- res = self.list_resources(self.predefined['implml_path'], recurse=True)
- res += super(Layer, self).list_implml()
+ res = self.list_resources(self.predefined['implml_path'], recurse=True,empty_folders=empty_folders)
+ res += super(Layer, self).list_implml(empty_folders)
return res
- def list_content(self):
+ def list_content(self,empty_folders=False):
"""
@return: array of content file references.
"""
- res = self.list_resources(self.predefined['content_path'], recurse=True)
- res += super(Layer, self).list_content()
+ res = self.list_resources(self.predefined['content_path'], recurse=True,empty_folders=empty_folders)
+ res += super(Layer, self).list_content(empty_folders)
return res
- def list_doc(self):
+ def list_doc(self,empty_folders=False):
"""
@return: array of document file references.
"""
- res = self.list_resources(self.predefined['doc_path'], recurse=True)
- res += super(Layer, self).list_doc()
+ res = self.list_resources(self.predefined['doc_path'], recurse=True,empty_folders=empty_folders)
+ res += super(Layer, self).list_doc(empty_folders)
return res
def confml_folder(self):
@@ -4210,6 +4245,25 @@
mapmodule = __import__('cone.public.mapping')
return mapmodule.public.mapping.BaseMapper()
+class RulemlEvalGlobals(Base):
+ """
+ Ruleml subelement of extensions element
+ """
+ refname = "_extension"
+ def __init__(self, value = None, file = None, **kwargs):
+ """
+ """
+ super(RulemlEvalGlobals,self).__init__(self.refname)
+ self.value = value
+ self.file = file
+
+ @classmethod
+ def get_script_file_full_path(self, child):
+ parent_config = child._find_parent(type=Configuration)
+ cpath = parent_config.get_full_path()
+ cpath = utils.resourceref.psplit_ref(cpath)[0]
+ path = utils.resourceref.join_refs([cpath, child.file])
+ return path
class Problem(object):
SEVERITY_ERROR = "error"