Package orm2 :: Module datatypes :: Class datetime_base
[hide private]
[frames] | no frames]

Class datetime_base

source code

object --+        
         |        
  property --+    
             |    
      datatype --+
                 |
                datetime_base
Known Subclasses:
datetime, time

This is the baseclass for datetime, date, and time. Writing a datetime datatype is more intricate matter than one would expect on first sight. The challenges that come with it are, among other things:

SQL backends approach these problems in diverse ways, which must be handled by specific classes in the backend's datatype module. Fortunately they all share a common denominator which I'm trying to work with here. There are three classes: date, time and datetime. On the Python side they use the datetime module (the timedelta, date and datetime classes for the time, data and datetime datatype respectively). Values provided as mx.DateTime instances by the database will be converted. Towards the database it will convert these into ISO compliant date representations, quoted like SQL string literals. This is going to just work in most situations.

If anyone feels like writing custom datetime datatypes for specific backends, mapping Python's new datatypes to PostgreSQL's timezone or DateTimeDelta capabilities or MySQL's ability to store illegal dates (with 0s in it), they are very welcome!

Instance Methods [hide private]
  sql_literal(self, dbobj)
Return an SQL literal representing the data managed by this property in dbobj.
  __set_from_result__(self, ds, dbobj, value)
  __convert__(self, value)
Return value converted as a Python object of the class assigned to this datatype.
  datetime_as_string(self, value)

Inherited from datatype: __delete__, __get__, __init__, __init_dbclass__, __select_after_insert__, __select_this_column__, __set__, __setattr__, add_widget, check_dbobj, data_attribute_name, isset, widget_specs

Inherited from property: __getattribute__, __new__

Inherited from object: __delattr__, __hash__, __reduce__, __reduce_ex__, __repr__, __str__


Class Variables [hide private]

Inherited from datatype: python_class, sql_literal_class

Inherited from property: fdel, fget, fset


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

sql_literal(self, dbobj)

source code 
Return an SQL literal representing the data managed by this property in dbobj.
Returns:
SQL literal as a string.
Overrides: datatype.sql_literal
(inherited documentation)

__set_from_result__(self, ds, dbobj, value)

source code 
None
Overrides: datatype.__set_from_result__

__convert__(self, value)

source code 
Return value converted as a Python object of the class assigned to this datatype.
Overrides: datatype.__convert__
(inherited documentation)

datetime_as_string(self, value)

source code 
None