Changeset 742 for WAeUP_SRP/trunk/Widgets.py
- Timestamp:
- 24 Oct 2006, 16:32:10 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Widgets.py
r714 r742 340 340 prefix = '' 341 341 reference = '' 342 343 342 def prepare(self, datastructure, **kw): ###( 344 343 """Prepare datastructure from datamodel.""" … … 346 345 v = datamodel[self.fields[0]] 347 346 widget_id = self.getWidgetId() 348 if v and type(v) is StringType: 349 p,b,n = v.split('-') 350 v = ScratchCardPin(v,b,n) 347 #import pdb;pdb.set_trace() 348 ## if v and type(v) is StringType: 349 ## p,b,n = v.split('-') 350 ## v = ScratchCardPin(v,b,n) 351 351 if v: 352 p = '%s' % v.p 352 353 b = '%s' % v.b 353 354 n = '%s' % v.n 354 355 else: 356 p = self.prefix 357 if p.startswith('@'): 358 p = getattr(self,self.prefix[1:])() 355 359 b = n = '' 360 v = ScratchCardPin(p,b,n) 356 361 datastructure[widget_id] = v 362 datastructure[widget_id+'_p'] = p 357 363 datastructure[widget_id+'_b'] = b 358 364 datastructure[widget_id+'_n'] = n … … 362 368 def validate(self, datastructure, **kw): 363 369 """Validate datastructure and update datamodel.""" 370 #import pdb;pdb.set_trace() 364 371 widget_id = self.getWidgetId() 365 372 v = datastructure[widget_id] 366 373 err = 0 367 p = self.prefix 374 prefix= self.prefix 375 if prefix.startswith('@'): 376 prefix= getattr(self,self.prefix[1:])() 368 377 b = datastructure[widget_id+'_b'].strip() 369 378 n = datastructure[widget_id+'_n'].strip() 370 379 pins = self.portal_pins 371 pin = "%(p )s%(b)s%(n)s" % vars()380 pin = "%(prefix)s%(b)s%(n)s" % vars() 372 381 if self.reference == "": 373 382 ref = str(self.portal_membership.getAuthenticatedMember()) 374 383 else: 375 384 ref = datastructure[self.reference] 376 #import pdb;pdb.set_trace() 377 ok = pins.searchAndSetRecord(pin,ref,self.prefix) 385 ok = pins.searchAndSetRecord(pin,ref,prefix) 378 386 while 1: 379 387 if ok == -2: … … 406 414 else: 407 415 datamodel = datastructure.getDataModel() 408 datamodel[self.fields[0]] = ScratchCardPin(self.prefix,b,n) 409 datastructure[widget_id] = ScratchCardPin(self.prefix,b,n) 416 datamodel[self.fields[0]] = ScratchCardPin(prefix,b,n) 417 datastructure[widget_id] = ScratchCardPin(prefix,b,n) 418 datastructure[widget_id+'_p'] = prefix 410 419 datastructure[widget_id+'_b'] = b 411 420 datastructure[widget_id+'_n'] = n 412 421 datastructure['s_id'] = s_id 413 #import pdb;pdb.set_trace()414 422 return not err 415 423 … … 428 436 v = datamodel[self.fields[0]] 429 437 if v and type(v) is StringType: 430 p ,b,n = v.split('-')431 v = ScratchCardPin(p ,b,n)438 prefix,b,n = v.split('-') 439 v = ScratchCardPin(prefix,b,n) 432 440 if v: 441 prefix= '%s' % v.p 433 442 b = '%s' % v.b 434 443 n = '%s' % v.n 435 444 else: 445 prefix= self.prefix 446 if prefix.startswith('@'): 447 prefix= getattr(self,self.prefix[1:])() 436 448 b = n = '' 437 if mode in ['edit', 'create']: 438 widget_id = self.getWidgetId() 439 datastructure[widget_id] = v 440 datastructure[widget_id+'_b'] = b 441 datastructure[widget_id+'_n'] = n 449 v = ScratchCardPin(prefix,b,n) 450 widget_id = self.getWidgetId() 451 datastructure[widget_id] = v 452 datastructure[widget_id+'_p'] = prefix 453 datastructure[widget_id+'_b'] = b 454 datastructure[widget_id+'_n'] = n 442 455 return meth(mode=mode, 443 456 datastructure=datastructure, 444 prefix=self.prefix,445 457 ) 446 458 ###)
Note: See TracChangeset for help on using the changeset viewer.