Changeset 2716 in products
- Timestamp:
- Aug 3, 2010 3:39:15 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.transmogrifier/branches/dictionary/quintagroup/transmogrifier/namespaces/atns.py
r1455 r2716 18 18 19 19 20 21 ####################################### 22 # Setup logging system # 23 ####################################### 24 import logging 25 DEFAULT_LOG = "/tmp/quintagroup.transmogrifier.log" 26 FORMAT = "[%(asctime)s]: %(message)s" 27 #FORMAT = "[%H:%M:%S]: %(message)s" 28 def createHandler(hndlr_cls, level, *args, **kwargs): 29 hndlr = hndlr_cls(*args, **kwargs) 30 hndlr.setLevel(level) 31 hndlr.setFormatter(logging.Formatter(FORMAT, datefmt="%H:%M:%S")) 32 return hndlr 33 34 # Very IMPORTANT create logger as logging.Logger NOT logging.getLogger !!! 35 logger = logging.Logger("Quintagroup Transmogrifier", logging.NOTSET) 36 logger.addHandler(createHandler( 37 logging.FileHandler, logging.DEBUG, DEFAULT_LOG)) 38 39 ####################################### 40 41 _marker = () 42 43 20 44 class ATAttribute(base.ATAttribute): 21 45 … … 25 49 if not values: 26 50 return 51 52 # if self.name in ['payablesMap', 'fieldMap']: 53 # import ipdb;ipdb.set_trace() 27 54 28 55 is_ref = self.isReference(instance) … … 61 88 node.appendChild(value_node) 62 89 else: 90 items = getattr(value, 'items', _marker) 91 if items is not _marker and callable(items): 92 type_attr = dom.createAttribute("type") 93 type_attr.value = "dict" 94 node.setAttributeNode( type_attr ) 63 95 value_node = dom.createTextNode(value) 64 96 node.appendChild(value_node) … … 81 113 if te is not None: 82 114 value = value.decode(te) 115 # process dictionary type 116 vtype = context.node.attrib.get('type', None) 117 if vtype and vtype=='dict': 118 try: 119 s = value.strip("{}\t\n") 120 # value = dict([map(lambda x:x.strip(" '\""), item.split("': '")) \ 121 # for item in s.split("', '")]) 122 value = dict([map(lambda x:x.strip(" '\""), item.split(": ")) \ 123 for item in s.split(", ")]) 124 except: 125 #import ipdb;ipdb.set_trace() 126 logger.error("Error on processing '%s' dict type field,\n"\ 127 " for object: '%s'\n " \ 128 " for the following data: '%s'" % (str(context.instance.id), 129 context.instance.absolute_url(), str(value))) 130 83 131 84 132 data = context.getDataFor(self.namespace.xmlns)
Note: See TracChangeset
for help on using the changeset viewer.