[storm] Bool database type

Drew Smathers drew.smathers at gmail.com
Sun Aug 5 06:48:08 BST 2007


For Bool-type columns in a class it looks as if this directly maps to
the equivalent boolean type (surprise) for the underlying database.
My problem is with tables where the boolean type is not used and
instead a single character (either '0'/'1', or 'Y'/'N') is used used
for this.  It seems like the only way to achieve this now with storm
is to write a custom property/variable like so:

YesNoBoolVariable(Variable):
  @staticmethod
  def _parse_set(value, from_db):
     ...
     return ('N', 'Y')[bool(value)]

YesNoBool(SimpleProperty):
  variable_class = YesNoBoolVariable

class Foo:
  ...
  ready = YesNoBool()

Is the above the only way to do this?

-- 
\\\\\/\"/\\\\\\\\\\\
\\\\/ // //\/\\\\\\\
\\\/  \\// /\ \/\\\\
\\/ /\/ / /\/ /\ \\\
\/ / /\/ /\  /\\\ \\
/ /\\\  /\\\ \\\\\/\
\/\\\\\/\\\\\/\\\\\\
               d.p.s



More information about the storm mailing list