Skip to content

Instantly share code, notes, and snippets.

@chbrown
Created April 17, 2010 21:48
Show Gist options
  • Save chbrown/369820 to your computer and use it in GitHub Desktop.
Save chbrown/369820 to your computer and use it in GitHub Desktop.
def prepare(self):
if not self.value or not self.value['end_datetime']:
self.children.end_datetime.value = datetime.now() + timedelta(hours=1)
self.children.program_owners.options = DBSession.query(ProgramOwner.program_owner_id, ProgramOwner.name).all()
self.children.venues.options = DBSession.query(Venue.venue_id, Venue.name).all()
self.children.users.options = [(u.user_id, u.fullname) for u in DBSession.query(User)]
# THIS PART -v
validatables = [self.children.program_owners, self.children.venues, self.children.users]
for validatable in validatables:
if isinstance(validatable.value, list) and isinstance(validatable.value[0], basestring) or \
isinstance(validatable.value, basestring):
validatable.value = validatable.validator._from_python(validatable.validator._to_python(validatable.value))
return super(EventFields, self).prepare()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment