Types in Python - Google Appengine
Posted
by Chris M
on Stack Overflow
See other posts from Stack Overflow
or by Chris M
Published on 2010-04-08T14:52:00Z
Indexed on
2010/04/08
14:53 UTC
Read the original article
Hit count: 317
python
|google-app-engine
Getting a bit peeved now;
I have a model and a class thats just storing a get request in the database; basic tracking.
class SearchRec(db.Model):
WebSite = db.StringProperty()#required=True
WebPage = db.StringProperty()
CountryNM = db.StringProperty()
PrefMailing = db.BooleanProperty()
DateStamp = db.DateTimeProperty(auto_now_add=True)
IP = db.StringProperty()
class AddSearch(webapp.RequestHandler):
def get(self):
searchRec = SearchRec()
searchRec.WebSite = self.request.get('WEBSITE')
searchRec.WebPage = self.request.get('WEBPAGE')
searchRec.CountryNM = self.request.get('COUNTRY')
searchRec.PrefMailing = bool(self.request.get('MAIL'))
searchRec.IP = self.request.get('IP')
Bool has my biscuit; I thought that setting bool(self.reque....) would set the type of the string but no matter what I pass it it still stores it as TRUE in the database. I had the same issue with using required=True on strings for the model; the damn thing kept saying that nothing was being passed... but it had.
Ta
© Stack Overflow or respective owner