Changeset 1414 in products
- Timestamp:
- Nov 26, 2009 11:05:20 AM (14 years ago)
- Location:
- quintagroup.transmogrifier/trunk
- Files:
-
- 6 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.transmogrifier/trunk
- Property svn:mergeinfo set to /quintagroup.transmogrifier/branches/plone-2.1/quintagroup.transmogrifier:1387-1389,1394-1413
-
quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/binary.py
r453 r1414 24 24 #self.excludekey = defaultMatcher(options, 'exclude-key', name, 'excluded_fields') 25 25 self.excludekey = options.get('exclude-key', '_excluded_fields').strip() 26 27 self.doc = minidom.Document() 26 28 27 29 def __iter__(self): … … 73 75 """ 74 76 field = obj.getField(field) 75 base_unit = field.getBaseUnit(obj) 77 # temporarily: 78 # dirty call, I know, just lazy to get method arguments 79 # TextField overrided getBaseUnit method but didn't follow API 80 try: 81 base_unit = field.getBaseUnit(obj, full=True) 82 except TypeError, e: 83 base_unit = field.getBaseUnit(obj) 76 84 fname = base_unit.getFilename() 77 85 ct = base_unit.getContentType() … … 81 89 82 90 def createManifest(self, binary_fields): 83 manifest = '<?xml version="1.0" ?>\n<manifest>\n' 84 for field, info in binary_fields.items(): 85 manifest += ' <field name="%s">\n' % field 86 manifest += ' <filename>%s</filename>\n' % info['filename'] 87 manifest += ' <mimetype>%s</mimetype>\n' % info['mimetype'] 88 manifest += ' </field>\n' 89 manifest += "</manifest>\n" 90 return manifest 91 doc = self.doc 92 93 root = doc.createElement('manifest') 94 for fname, info in binary_fields.items(): 95 # create field node 96 field = doc.createElement('field') 97 98 # set name attribute 99 attr = doc.createAttribute('name') 100 attr.value = fname 101 field.setAttributeNode(attr) 102 103 # create filename node 104 filename = doc.createElement('filename') 105 filename.appendChild(doc.createTextNode(info['filename'])) 106 field.appendChild(filename) 107 108 # create mimetype node 109 mimetype = doc.createElement('mimetype') 110 mimetype.appendChild(doc.createTextNode(info['mimetype'])) 111 field.appendChild(mimetype) 112 113 root.appendChild(field) 114 115 doc.appendChild(root) 116 117 try: 118 data = doc.toprettyxml(indent=' ', encoding='utf-8') 119 except UnicodeDecodeError, e: 120 # all comments are strings encoded in 'utf-8' and they will properly 121 # saved in xml file, but if we explicitly give 'utf-8' encoding 122 # UnicodeDecodeError will be raised when they have non-ascii chars 123 data = doc.toprettyxml(indent=' ') 124 125 doc.unlink() 126 return data 127 91 128 92 129 class FileImporterSection(object): -
quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/manifest.py
r1240 r1414 21 21 self.fileskey = options.get('files-key', '_files').strip() 22 22 23 self.doc = minidom.Document() 24 23 25 def __iter__(self): 24 26 for item in self.previous: … … 41 43 if not entries: 42 44 return None 43 manifest = '<?xml version="1.0" ?>\n<manifest>\n' 45 46 doc = self.doc 47 root = doc.createElement('manifest') 48 44 49 for obj_id, obj_type in entries: 45 manifest += ' <record type="%s">%s</record>\n' % (obj_type, obj_id) 46 manifest += "</manifest>\n" 47 return manifest 50 # create record 51 record = doc.createElement('record') 52 53 # set type attribute 54 attr = doc.createAttribute('type') 55 attr.value = obj_type 56 record.setAttributeNode(attr) 57 58 # add object id 59 text = doc.createTextNode(obj_id) 60 record.appendChild(text) 61 62 root.appendChild(record) 63 64 doc.appendChild(root) 65 66 try: 67 data = doc.toprettyxml(indent=' ', encoding='utf-8') 68 except UnicodeDecodeError, e: 69 # all comments are strings encoded in 'utf-8' and they will properly 70 # saved in xml file, but if we explicitly give 'utf-8' encoding 71 # UnicodeDecodeError will be raised when they have non-ascii chars 72 data = doc.toprettyxml(indent=' ') 73 74 doc.unlink() 75 return data 48 76 49 77 class ManifestImporterSection(object): -
quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/marshall.py
r527 r1414 15 15 from Products.Archetypes.event import ObjectInitializedEvent 16 16 from Products.Archetypes.event import ObjectEditedEvent 17 18 # override Marshall atxml namespaces 19 from quintagroup.transmogrifier import namespaces 20 17 21 18 22 class MarshallerSection(object):
Note: See TracChangeset
for help on using the changeset viewer.