Commit 4c4c716c by aa.gusti

template

1 parent 62c38f60
...@@ -11,6 +11,7 @@ from zope.sqlalchemy import register ...@@ -11,6 +11,7 @@ from zope.sqlalchemy import register
_logging = logging.getLogger(__name__) _logging = logging.getLogger(__name__)
class MySession(Session): class MySession(Session):
def execute(self, clause, params=None, mapper=None, **kw): def execute(self, clause, params=None, mapper=None, **kw):
# Your magic with clause here # Your magic with clause here
...@@ -68,7 +69,8 @@ class CommonModel(object): ...@@ -68,7 +69,8 @@ class CommonModel(object):
def from_dict(self, values, date_format="%d-%m-%Y"): def from_dict(self, values, date_format="%d-%m-%Y"):
for column in self.__table__.columns: for column in self.__table__.columns:
if column.name in values: if column.name in values:
_logging.debug(f"{column.name}: {column.type}: {values[column.name]}") _logging.debug(
f"{column.name}: {column.type}: {values[column.name]}")
if type(column.type) is DateTime and date_format: if type(column.type) is DateTime and date_format:
if values[column.name] and type(values[column.name]) is String: if values[column.name] and type(values[column.name]) is String:
setattr(self, column.name, setattr(self, column.name,
...@@ -220,4 +222,4 @@ class NamaModel(KodeModel): ...@@ -220,4 +222,4 @@ class NamaModel(KodeModel):
@classmethod @classmethod
def get_list(cls): def get_list(cls):
return cls.query_list().all()
\ No newline at end of file \ No newline at end of file
return cls.query_list().all()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!