On Monday, March 30, 2015 at 9:06:48 PM UTC-4, Bao Niu wrote:
>
> To make sure that I understand it right, did you mean "hybrid attribute 
> methods" when you mentioned "property methods" here? Thanks
>

No, just simple property methods.   A super-simple first Minimum Viable 
Product/iteration might be:

    class Foo(object):
          utc_timestamp = Datetime() 
          utc_timezone = Integer()

          def as_local_time(self):
                 """"call this to generate a timezone aware object from the 
database time"""
                 return some_function(self.utc_timestamp, utc_timezone)

Over time, you could add in getter/setters or look into other ways of 
handling this:

or You could integrate SqlAlchemy's Hybird Attribute Methods
or you could use composite columns 
(http://docs.sqlalchemy.org/en/latest/orm/composites.html)
i think you might be able to use a TypeDecorator too 
( http://docs.sqlalchemy.org/en/latest/core/custom_types.html)

A few of the sqlalchemy approaches can even let you generate the SQL the db 
would use on the backend for comparisons.  Until you get to that point 
though, it's pretty simple to have a v1 that is very flexible.

The general point is that there are a lot of ways to handle your situation, 
and keep actual "time" objects in the database.  


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to