# Path: kokemomo/plugins/engine/model/km_storage/impl/km_rdb_adapter.py
# class BaseModel(object):
# class KMRDBAdapter(BaseAdapter):
# class Transaction(object):
#     def __tablename__(cls):
#     def __repr__(self):
#     def validate(self):
#     def save(self, validate=True):
#     def delete(self):
#     def all(cls, order=None, commit=True):
#     def get(cls, id, commit=True):
#     def delete_by_id(cls, id):
#     def delete_by_condition(cls, **kwargs):
#     def find(cls, order=None, commit=True, **kwargs):
#     def __init__(self, rdb_path, options):
#     def metadata(self):
#     def init(self, rdb_path=None, options={}):
#     def drop_all(self):
#     def add(self, *args, **kwargs):
#     def delete(self, *args, **kwargs):
#     def commit(self):
#     def set(self, *args, **kwargs):
#     def rollback(self):
#     def get(self, *args, **kwargs):
# def rollback():
#     def begin(cls):
#     def add(cls, *args, **kwargs):
#     def delete(cls, *args, **kwargs):
#     def commit(cls):
#     def rollback(self):
# 
# Path: kokemomo/plugins/engine/model/km_validate_error.py
# class KMValidateError(object):
# 
#     def __init__(self):
#         self.list = []
# 
#     def add_data(self, id=None, message='', option=None):
#         data = {}
#         data['id'] = id
#         data['message'] = message
#         data['option'] = option
#         self.list.append(data)
# 
#     def have(self, id=None):
#         for data in self.list:
#             if data['id'] == id:
#                 return True
#         return False
# 
#     def get(self, id=None):
#         for data in self.list:
#             if data['id'] == id:
#                 return data
#         return None
# 
#     def size(self):
#         return len(self.list)


from kokemomo.plugins.engine.utils.km_model_utils import *
from kokemomo.plugins.engine.model.km_storage.impl.km_rdb_adapter import adapter
from kokemomo.plugins.engine.model.km_validate_error import KMValidateError

    def __init__(self, data=None):
        if data is None:
            self.title = ''
            self.caption = ''
            self.article = ''
            self.tag = ''
            self.post_date = datetime.datetime.now()
        else:
            self.set_data(data)

    def __repr__(self):
        return create_repr_str(self)

    def get_json(self):
        return create_json(self)


    def set_data(self, data):
        self.error = None
        self.info_id = data.get_request_parameter('info_id')
        self.category_id = data.get_request_parameter('category_id')
        self.title = data.get_request_parameter('title', default='')
        self.caption = data.get_request_parameter('caption', default='')
        self.article = data.get_request_parameter('article', default='')
        self.tag = data.get_request_parameter('tag', default='')
        self.post_date = datetime.datetime.now()


    def validate(self):

# Path: kokemomo/plugins/engine/model/km_storage/impl/km_rdb_adapter.py
# class BaseModel(object):
# class KMRDBAdapter(BaseAdapter):
# class Transaction(object):
#     def __tablename__(cls):
#     def __repr__(self):
#     def validate(self):
#     def save(self, validate=True):
#     def delete(self):
#     def all(cls, order=None, commit=True):
#     def get(cls, id, commit=True):
#     def delete_by_id(cls, id):
#     def delete_by_condition(cls, **kwargs):
#     def find(cls, order=None, commit=True, **kwargs):
#     def __init__(self, rdb_path, options):
#     def metadata(self):
#     def init(self, rdb_path=None, options={}):
#     def drop_all(self):
#     def add(self, *args, **kwargs):
#     def delete(self, *args, **kwargs):
#     def commit(self):
#     def set(self, *args, **kwargs):
#     def rollback(self):
#     def get(self, *args, **kwargs):
# def rollback():
#     def begin(cls):
#     def add(cls, *args, **kwargs):
#     def delete(cls, *args, **kwargs):
#     def commit(cls):
#     def rollback(self):
# 
# Path: kokemomo/plugins/engine/model/km_validate_error.py
# class KMValidateError(object):
# 
#     def __init__(self):
#         self.list = []
# 
#     def add_data(self, id=None, message='', option=None):
#         data = {}
#         data['id'] = id
#         data['message'] = message
#         data['option'] = option
#         self.list.append(data)
# 
#     def have(self, id=None):
#         for data in self.list:
#             if data['id'] == id:
#                 return True
#         return False
# 
#     def get(self, id=None):
#         for data in self.list:
#             if data['id'] == id:
#                 return data
#         return None
# 
#     def size(self):
#         return len(self.list)


# Path: kokemomo/plugins/blog/model/km_blog_article.py
from kokemomo.plugins.engine.utils.km_model_utils import *
from kokemomo.plugins.engine.model.km_storage.impl.km_rdb_adapter import adapter
from kokemomo.plugins.engine.model.km_validate_error import KMValidateError


    def __init__(self, data=None):
        if data is None:
            self.title = ''
            self.caption = ''
            self.article = ''
            self.tag = ''
            self.post_date = datetime.datetime.now()
        else:
            self.set_data(data)

    def __repr__(self):
        return create_repr_str(self)

    def get_json(self):
        return create_json(self)


    def set_data(self, data):
        self.error = None
        self.info_id = data.get_request_parameter('info_id')
        self.category_id = data.get_request_parameter('category_id')
        self.title = data.get_request_parameter('title', default='')
        self.caption = data.get_request_parameter('caption', default='')
        self.article = data.get_request_parameter('article', default='')
        self.tag = data.get_request_parameter('tag', default='')
        self.post_date = datetime.datetime.now()


    def validate(self):

        self.error = KMValidateError()