Changeset 12258
- Timestamp:
- 18 Dec 2014, 14:44:30 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/app.py
r12256 r12258 42 42 grok.implements(ICompany) 43 43 44 _curr_con_id = 10145 46 44 # Setup authentication for this app. Note: this is only 47 45 # initialized, when a new instance of this app is created. … … 54 52 self.setup() 55 53 return 56 57 @property58 def unique_contract_id(self):59 """A unique contract id for all contract objects in customers.60 61 The contract id returned is guaranteed to be unique.62 63 Once a contract id was issued, it won't be issued again.64 65 Obtaining an contract id is currently not thread-safe but can be66 made easily by enabling commented lines.67 """68 # lock.acquire() # lock data69 new_id = u'c%s' % (self._curr_con_id)70 self._curr_con_id += 171 # self._p_changed = True72 # commit()73 # lock.release() # end of lock74 return new_id75 54 76 55 def setup(self): -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py
r12256 r12258 406 406 return None 407 407 408 #documents = self.getParent(row, site)409 #if documents is None:410 # return None411 #document_id = row.get('document_id', None)412 #if document_id is None:413 # return None414 #entry = documents.get(document_id)415 #return entry416 417 408 def updateEntry(self, obj, row, site, filename): 418 409 """Update obj to the values given in row. … … 496 487 if contract_id is None: 497 488 return None 498 entry = contracts.get(contract_id) 499 return entry 489 cat = queryUtility(ICatalog, name='contracts_catalog') 490 results = list(cat.searchResults(contract_id=(contract_id, contract_id))) 491 if results: 492 return results[0] 493 return None 500 494 501 495 def updateEntry(self, obj, row, site, filename): 502 496 """Update obj to the values given in row. 503 497 """ 498 # Remove contract_id from row if empty 499 if 'contract_id' in row and row['contract_id'] in (None, IGNORE_MARKER): 500 row.pop('contract_id') 504 501 items_changed = super(ContractProcessor, self).updateEntry( 505 502 obj, row, site, filename) 506 503 customer = self.getParent(row, site).__parent__ 507 504 customer.__parent__.logger.info( 508 '%s - %s - %s - updated: %s' 509 % (self.name, filename, customer.customer_id, items_changed)) 505 '%s - %s - %s - %s - updated: %s' 506 % (self.name, filename, customer.customer_id, obj.contract_id, 507 items_changed)) 510 508 return 511 509 512 510 def addEntry(self, obj, row, site): 513 511 parent = self.getParent(row, site) 514 contract_id = row['contract_id'].strip('#') 515 parent[contract_id] = obj 516 # Reset _curr_con_id if contract_id has been imported 517 site = grok.getSite() 518 if row.get('contract_id', None) not in (None, IGNORE_MARKER): 519 site._curr_con_id -= 1 512 parent.addContract(obj) 520 513 return 521 514 … … 541 534 if class_name != self.factory_name.strip('waeup.'): 542 535 errs.append(('class_name','wrong processor')) 543 try:544 # Correct con_id counter. As the IConverter for contracts545 # creates contract objects that are not used afterwards, we546 # have to fix the site-wide con_id counter.547 site = grok.getSite()548 site._curr_con_id -= 1549 except (KeyError, TypeError, AttributeError):550 pass551 # We have to check contract_id.552 contract_id = row.get('contract_id', None)553 if mode == 'create':554 if not contract_id:555 contract_id = generate_contract_id()556 conv_dict['contract_id'] = contract_id557 return errs, inv_errs, conv_dict558 cat = queryUtility(ICatalog, name='contracts_catalog')559 results = list(560 cat.searchResults(contract_id=(contract_id, contract_id)))561 if results:562 # contract_id must not exist.563 errs.append(('contract_id','id exists'))564 else:565 if not contract_id.startswith('c'):566 errs.append(('contract_id','invalid format'))567 536 return errs, inv_errs, conv_dict -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12256 r12258 1165 1165 pnav = 4 1166 1166 1167 form_fields = grok.AutoFields(IContract).omit('product_object') 1167 form_fields = grok.AutoFields(IContract).omit( 1168 'product_object', 'contract_id') 1168 1169 1169 1170 @property … … 1180 1181 # classes depending on the contype parameter given in form. 1181 1182 contract = createObject('waeup.%s' % contype) 1183 self.applyData(contract, **data) 1182 1184 self.context.addContract(contract) 1183 1185 contype = getUtility(ICustomersUtils).SELECTABLE_CONTYPES_DICT[contype] … … 1227 1229 @property 1228 1230 def form_fields(self): 1229 return grok.AutoFields(self.context.form_fields_interface) 1231 return grok.AutoFields(self.context.form_fields_interface).omit( 1232 'contract_id') 1230 1233 1231 1234 @property … … 1247 1250 @property 1248 1251 def form_fields(self): 1249 return grok.AutoFields(self.context.edit_form_fields_interface) 1252 return grok.AutoFields(self.context.edit_form_fields_interface).omit( 1253 'contract_id') 1250 1254 1251 1255 def update(self): -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/contracts.py
r12210 r12258 27 27 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 28 28 from waeup.ikoba.interfaces import MessageFactory as _ 29 from waeup.ikoba.interfaces import IIkobaUtils, IObjectHistory, VERIFIED 29 from waeup.ikoba.interfaces import ( 30 IIkobaUtils, IObjectHistory, VERIFIED, IIDSource) 30 31 from waeup.ikoba.customers.interfaces import ( 31 32 IContractsContainer, ICustomerNavigation, … … 75 76 super(ContractBase, self).__init__() 76 77 # The site doesn't exist in unit tests 77 try: 78 self.contract_id = generate_contract_id() 79 except AttributeError: 80 self.contract_id = u'c999' 78 source = getUtility(IIDSource) 79 self.contract_id = unicode(source.get_hex_uuid()) 81 80 self.last_product_id = None 82 81 return -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12214 r12258 265 265 266 266 """ 267 contract_id = Attribute('Contract Identifier')268 267 history = Attribute('Object history, a list of messages') 269 268 state = Attribute('Returns the contract state') … … 280 279 translated_class_name = Attribute('Translatable class name') 281 280 281 contract_id = schema.TextLine( 282 title = _(u'Contract Id'), 283 required = False, 284 ) 285 282 286 title = schema.TextLine( 283 287 title = _(u'Contract Title'), -
main/waeup.ikoba/trunk/src/waeup/ikoba/utils/batching.py
r12250 r12258 227 227 # Computed attributes can't be set. 228 228 continue 229 log_value = getattr(value, 'any_id', value) 229 log_value = getattr(value, 'product_id', value) 230 log_value = getattr(value, 'document_id', log_value) 230 231 changed.append('%s=%s' % (key, log_value)) 231 232
Note: See TracChangeset for help on using the changeset viewer.