def showEmail(self): req = self.REQUEST order = req['order'] emailtemplate = req['emailtemplate'] f = open(os.path.join(ordersdir, order)) pkl = cPickle.load(f) f.close() checkout = pkl['checkout'] for item in checkout.items( ): # propagate contents of checkout onto me so dtml can find k, v = item setattr(self, k, v) self.ordnum = os.path.splitext(order)[0] # self.shipper = eval (self.shipmeth) [0] self.tracknum = req.tracknum self.shipper = self.shippers[req.shipper].title_or_id() self.trackurl = self.shippers[req.shipper](self) self.cctype = ccards.vendor(self.ccnum) self.ccend = self.ccnum[-4:] # self.emailtemplate = emailtemplate should stay in request self.editing = hasattr(req, 'editemail') self.saving = hasattr(req, 'saveemail') if hasattr(req, 'emailbody'): self.emailbody = req.emailbody else: self.emailbody = self.emails[emailtemplate](self) # return '%s<pre>%s</pre>' % (self.showemailactions (self), self.emails [emailtemplate] (self)) # calling renders content return self.showemail(self) # calling renders content
def showEmail (self): req = self.REQUEST order = req ['order'] emailtemplate = req ['emailtemplate'] f = open (os.path.join (ordersdir, order)) pkl = cPickle.load (f) f.close() checkout = pkl ['checkout'] for item in checkout.items(): # propagate contents of checkout onto me so dtml can find k,v = item setattr (self, k, v) self.ordnum = os.path.splitext (order) [0] # self.shipper = eval (self.shipmeth) [0] self.tracknum = req.tracknum self.shipper = self.shippers [req.shipper].title_or_id() self.trackurl = self.shippers [req.shipper] (self) self.cctype = ccards.vendor (self.ccnum) self.ccend = self.ccnum [-4:] # self.emailtemplate = emailtemplate should stay in request self.editing = hasattr (req, 'editemail') self.saving = hasattr (req, 'saveemail') if hasattr (req, 'emailbody'): self.emailbody = req.emailbody else: self.emailbody = self.emails [emailtemplate] (self) # return '%s<pre>%s</pre>' % (self.showemailactions (self), self.emails [emailtemplate] (self)) # calling renders content return self.showemail (self) # calling renders content
def check (self, req): self.error = '' if req.paymeth != 'byccard': return '' self.value = ccards.numbersOnly (self.value) dt = DateTime.DateTime() if self.value: if upper (self.value) != lower (self.value): self.error = 'Improperly formed credit card number' # should check for nonnum chars, too elif not ccards.validate (self.value): self.error = 'Invalid %s number' % ccards.vendor (self.value) elif ccards.vendor (self.value) not in ('MasterCard', 'Visa', 'Amex', 'Discover'): self.error = 'We only accept Visa, MasterCard, Discover, and Amex' elif int (req.ccyear or '0') <= dt.year() and int (req.ccmonth or '0') < dt.month(): #raise Exception (req.ccyear, req.ccmonth, dt.year(), dt.month(), dt) self.error = 'Expired card' return self.error
def renderout (self): if self.value: return '%s card ending in %i' % (ccards.vendor (self.value), long (self.value) % 10000) else: return ''