configurationengine/source/plugins/common/ConeContentPlugin/contentplugin/contentmlparser.py
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
child 5 d2c80f5cab53
equal deleted inserted replaced
2:87cfa131b535 3:e7e0ae78773e
    58 
    58 
    59     def get_configuration(self, configuration):
    59     def get_configuration(self, configuration):
    60         self.configuration = configuration
    60         self.configuration = configuration
    61 
    61 
    62     def path_convert(self, path):
    62     def path_convert(self, path):
    63         (drive, tail) = os.path.splitdrive(path)
    63         match = re.match('([a-zA-Z]:)(.*)', path)
    64         return tail.lstrip('\\/')
    64         if match:
       
    65             path = match.group(2)
       
    66         return path.lstrip('\\/')
    65 
    67 
    66     def get_dir(self):
    68     def get_dir(self):
    67         if self.configuration and ConfmlRefs.is_confml_ref(self._dir):
    69         if self.configuration and ConfmlRefs.is_confml_ref(self._dir):
    68             parts = self._dir.split(ConfmlRefs.ref_separator)
    70             parts = self._dir.split(ConfmlRefs.ref_separator)
    69             for (index, part) in enumerate(parts):
    71             for (index, part) in enumerate(parts):
   149                         cref = ConfmlRefs.get_confml_ref(elem)
   151                         cref = ConfmlRefs.get_confml_ref(elem)
   150                         try:
   152                         try:
   151                             # change None value to empty string
   153                             # change None value to empty string
   152                             cvalue = dview.get_feature(cref).value or ''
   154                             cvalue = dview.get_feature(cref).value or ''
   153                             if utils.is_list(cvalue):
   155                             if utils.is_list(cvalue):
   154                                 cvalue = ", ".join(cvalue)
   156                                 # Allow only strings (mainly filter out Nones)
       
   157                                 cvalue = filter(lambda x: isinstance(x, basestring), cvalue)
       
   158                                 cvalue = ", ".join([v or '' for v in cvalue])
   155                             key_list[index] = cvalue
   159                             key_list[index] = cvalue
   156                         except exceptions.NotFound:
   160                         except exceptions.NotFound:
   157                             logging.getLogger('cone.content').error("Feature ref '%s' in include key '%s' not found." % (cref,key))
   161                             logging.getLogger('cone.content').error("Feature ref '%s' in include key '%s' not found." % (cref,key))
   158         return data
   162         return data
   159 
   163 
   446             if matchref:
   450             if matchref:
   447                 ref = matchref.group(1)
   451                 ref = matchref.group(1)
   448                 if not ref in ret:
   452                 if not ref in ret:
   449                     ret.append(matchref.group(1))
   453                     ret.append(matchref.group(1))
   450             else:
   454             else:
   451 				ret.append(p)
   455                 ret.append(p)
   452         return ret
   456         return ret