views:

38

answers:

1
class Person(db.Model):
  first_name=db.StringProperty()
  middle_name=db.StringProperty()
  last_name=db.StringProperty()

p1=Person(first_name='john',                 last_name='smith')
p2=Person(first_name='john',middle_name=None,last_name='smith')
p3=Person(first_name='john',middle_name='',  last_name='smith')

p1 and p2 is the same with middle_name = None

p3 has middle_name = empty string

Which is better to work with?

In SQL, I tend to set columns to not null default ''

+2  A: 

They're completely different. One (None) is equivalent to SQL NULL. This can mean they don't have a middle name or you don't know it. '' means they do have a middle name, of length 0. This is almost never the case.

Matthew Flaschen
I know what you mean, but an empty string is exactly what I'll get if the form field is left unfilled. middle_name=cgi.escape(self.request.get('middle_name'))
Then you need to explicitly map from HTML form data -> database data.
Matthew Flaschen