#!/usr/bin/python
# -*- encoding: utf-8 -*-
"""

"""
__author__ = 'Martin Martimeo <martin@martimeo.de>'
__date__ = '30.08.13 - 18:38'

from sqlalchemy import schema, text
from sqlalchemy.ext.declarative import declarative_base, declared_attr

metadata = schema.MetaData()

class Base(object):
    """
        Base class for all database models
    """

    @declared_attr
    def __table_args__(cls):
        return {'useexisting': True}


    def __asdict__(self):
        values = vars(self)
        for attr in self.__mapper__.columns.keys():
            if attr in values:
                yield attr, values[attr]

    @declared_attr
    def created(self):
        """
            Creation Time of object
        """
        from .types.date import DateTime

        return DateTime(server_default=text('now'), info=dict(readonly=True))

    @declared_attr
    def modified(self):
        """
            Modification Timestamp
        """
        from .types.date import DateTime

        return DateTime(server_default=text('now'), server_onupdate=text('now'), info=dict(readonly=True))

    def __repr__(self):
        return "<%s %s />" % (self.__class__.__name__, " ".join("%s='%s'" % (k, v) for k, v in self.__asdict__()))


Base = declarative_base(metadata=metadata, cls=Base)


@@ -164,16 +164,22 @@
 ma, text
+, func
 %0Afrom sq
@@ -273,16 +273,17 @@
 Data()%0A%0A
+%0A
 class Ba
@@ -803,26 +803,25 @@
 default=
-text('now'
+func.now(
 ), info=
@@ -1025,26 +1025,25 @@
 default=
-text('now'
+func.now(
 ), serve
@@ -1057,18 +1057,17 @@
 ate=
-text('now'
+func.now(
 ), i

Fix created/modified timestamp func