- Timestamp:
- 7 Dec 2014, 10:07:29 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py
r12128 r12161 21 21 import os 22 22 import grok 23 from hashlib import md5 23 24 from zope.component import queryUtility, getUtility 24 25 from zope.component.interfaces import IFactory … … 66 67 grok.baseclass() 67 68 69 filenames = () 70 68 71 @property 69 72 def customer(self): … … 105 108 return 106 109 110 @property 111 def connected_files(self): 112 store = getUtility(IExtFileStore) 113 files = [] 114 try: 115 for filename in self.filenames: 116 attrname = filename.replace('.','_') 117 file = store.getFileByContext(self, attr=filename) 118 files.append((attrname, file)) 119 except AttributeError: 120 # In unit tests we don't have a customer to 121 # determine the file path. 122 return 123 return files 124 125 def setMD5(self): 126 """Set md5 checksum attribute for all files connected to this document. 127 """ 128 for file in self.connected_files: 129 attrname = '%s_md5' % file[0] 130 checksum = md5(file[1].read()).hexdigest() 131 setattr(self, attrname, checksum) 132 return 133 107 134 108 135 class CustomerSampleDocument(CustomerDocumentBase): 109 136 """This is a sample customer document. 110 137 """ 138 139 filenames = ('sample',) 111 140 112 141 CustomerSampleDocument = attrs_to_fields(CustomerSampleDocument)
Note: See TracChangeset for help on using the changeset viewer.