Changeset 3325 for WAeUP_SRP/base
- Timestamp:
- 12 Mar 2008, 14:06:44 (17 years ago)
- Location:
- WAeUP_SRP/base
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/Upload.py
r3319 r3325 56 56 NO_KEY = NO_KEY 57 57 IGNORE = IGNORE 58 def getImporter(self): 59 importer_name = ''.join([part.capitalize() for part in self.getContent().import_layout.split('_')]) 60 importer = eval("%sImport" % importer_name)(self) 61 return importer 62 58 63 security.declareProtected(View,"Title") ###( 59 64 def Title(self): … … 67 72 doc = self.getContent() 68 73 csv_path = os.path.join(storage_path,doc.filename) 69 importer_name = ''.join([part.capitalize() for part in self.getContent().import_layout.split('_')]) 70 importer = eval("%sImport" % importer_name)(self) 74 importer = self.getImporter() 71 75 msg = '' 72 76 invalid_keys = [] … … 99 103 def getKeys(self): 100 104 """return the valid keys for headline""" 101 importer_name = ''.join([part.capitalize() for part in self.getContent().import_layout.split('_')]) 102 importer = eval("%sImport" % importer_name)(self) 105 importer = self.getImporter() 103 106 keys = importer.schema.keys() 104 107 keys.sort() … … 113 116 ###) 114 117 118 security.declareProtected(ModifyPortalContent,"getPending") ###( 119 def getPending(self): 120 """return pending-data""" 121 importer = self.getImporter() 122 data = open(importer.pending_path).read() 123 return importer.pending_fn,data 124 125 security.declareProtected(ModifyPortalContent,"getPending") ###( 126 def getErrors(self): 127 """return import_errors""" 128 import tempfile 129 importer = self.getImporter() 130 lines = [] 131 filename = self.getContent().filename 132 data = open(importer.pending_path) 133 reader = csv.reader(data) 134 headline = reader.next() 135 reader = csv.DictReader(data,headline) 136 # imported_from_pos = headline.index('imported_from') 137 # imported_line_nr_pos = headline.index('imported_line_nr') 138 out_file = tempfile.TemporaryFile() 139 writer = csv.DictWriter(out_file, 140 importer.info.keys(), 141 extrasaction='ignore') 142 lines += dict([(k,k) for k in importer.info.keys()]), 143 #import pdb;pdb.set_trace() 144 for item in reader: 145 if item["imported_from"] == filename: 146 lines += item, 147 writer.writerows(lines) 148 out_file.seek(0) 149 return out_file.read() 150 115 151 security.declareProtected(ModifyPortalContent,"editHeadline") ###( 116 152 def editHeadline(self,key_pairs): 117 153 """edit headline""" 118 importer_name = ''.join([part.capitalize() for part in self.getContent().import_layout.split('_')])119 importer = eval("%sImport" % importer_name)(self)120 154 csv_path = os.path.join(storage_path,self.filename) 121 155 reader = csv.reader(open(csv_path,"rb")) -
WAeUP_SRP/base/WAeUPImport.py
r3320 r3325 103 103 info = {} 104 104 info['imported_from'] = '' 105 info['imported_by'] = self.imported_by 105 info['import_line_nr'] = 0 106 info['imported_by'] = self.imported_by 106 107 info['import_date'] = self.import_date.strftime("%d/%m/%y %H:%M:%S") 107 108 info['error'] = '' … … 128 129 if os.path.exists(self.pending_path): 129 130 datafile = open(self.pending_path,"r") 130 pending_csv_reader = csv.DictReader(datafile,self.csv_keys,) 131 pending_csv_reader.next() # skip headline 131 reader = csv.reader(datafile) 132 old_headline = reader.next() 133 #datafile.seek(0) 134 pending_csv_reader = csv.DictReader(datafile,old_headline,) 135 #pending_csv_reader.next() # skip headline 132 136 for item in pending_csv_reader: 133 137 digest = makeDigest(item,self.data_keys) … … 169 173 while True: 170 174 if len(values) != len(import_keys): 171 msg += " + %d fields in headline but %d values +" % (len(import_keys),len(values))175 msg += "%d fields in headline but %d values" % (len(import_keys),len(values)) 172 176 break 173 177 for k in import_keys: 174 178 if k in singels: 175 179 keys += (k,'%s' % k,values[i],'(duplicate)'), 176 msg += (" + duplicate %s +" % k)180 msg += ("duplicate %s," % k) 177 181 keys[singels.index(k)] = (k,'%s' % k,values[singels.index(k)],'(duplicate)') 178 182 elif k in invalid_keys and not k.startswith(IGNORE): … … 186 190 ###) 187 191 ###) 188 189 192 190 193 class ApplicationImport(WAeUPImport):###( -
WAeUP_SRP/base/WAeUPTool.py
r3321 r3325 936 936 da['jamb_sex'] = sex 937 937 da['jamb_age'] = brain.jamb_age 938 da['app_reg_pin'] = brain.pin938 #da['app_ac_pin'] = brain.pin 939 939 da['jamb_lga'] = brain.jamb_lga 940 940 da['jamb_state'] = brain.jamb_state … … 1412 1412 #current = importer.current 1413 1413 import_date = importer.import_date 1414 imported_by = importer.imported_by1415 1414 # 1416 1415 # not_imported … … 1565 1564 data_string = ", ".join("%s: %s" % (k,v) for k,v in mapping.items()) 1566 1565 info['error'] = error 1566 info['import_line_nr'] = count + 1 1567 1567 mapping.update(info) 1568 1568 log_list = [] … … 1639 1639 #mapping['import_date'] = DateTime.DateTime() 1640 1640 mapping['import_date'] = import_date 1641 mapping['imported_by'] = imported_by1641 mapping['imported_by'] = member 1642 1642 mapping['import_message'] = msg 1643 1643 upload_doc.edit(mapping = mapping) -
WAeUP_SRP/base/skins/waeup_upload/uploads_form.pt
r3319 r3325 180 180 <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content"> 181 181 <tr> 182 <th>Download</th> 182 183 <th>File in Archive</th> 183 184 <th>Data Layout</th> … … 190 191 <tr tal:repeat="row info/imported" 191 192 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')"> 192 <td tal:condition="nothing"> <a href="view" tal:attributes="href string:${row/url}"> <span tal:content="row/id" /></a> </td> 193 <td> <a href="view" tal:attributes="href string:${row/url}/download_pending">pending</a> <br /> 194 <a href="view" tal:attributes="href string:${row/url}/download_errors">errors</a> </td> 193 195 <td tal:content="string:${row/id}.done" ></td> 194 196 <td tal:content="row/import_layout"></td> -
WAeUP_SRP/base/skins/waeup_upload/uploads_index.py
r3316 r3325 87 87 row['msg'] = import_message 88 88 if getattr(doc,'import_date',''): 89 row['import_date'] = doc.import_date .strftime("%d/%m/%y %H:%M:%S")89 row['import_date'] = doc.import_date 90 90 else: 91 91 row['import_date'] = '' 92 92 add_to = imported 93 93 94 else: 94 95 row['msg'],row['fields'] = doc['checkKeys']()
Note: See TracChangeset for help on using the changeset viewer.