# Path: turbo/mongo_model.py
# def _record(x):
# def convert_to_record(func):
#     def wrapper(self, *args, **kwargs):
#     def utctimestamp(seconds=None):
#     def timestamp():
#     def datetime(dt=None):
#     def utcdatetime(dt=None):
#     def to_one_str(cls, value, *args, **kwargs):
#     def to_str(cls, values, callback=None):
#     def _wrapper_to_one_str(value):
#     def default_encode(v):
#     def json_encode(v):
#     def json_decode(v):
#     def to_objectid(objid):
#     def create_objectid():
#     def instance(cls, name):
#     def import_model(cls, ins_name):
#     def default_record():
# def collection_method_call(turbo_connect_ins, name):
#     def outwrapper(func):
#         def wrapper(*args, **kwargs):
#     def __init__(self, model_ins, db_collect=None):
#     def __getattr__(self, name):
#     def __getitem__(self, name):
#     def _init(self, db_name, _mongo_db_mapping):
#     def _to_primary_key(self, _id):
#     def __setitem__(self, k, v):
#     def __getitem__(self, k):
#     def __str__(self):
#     def sub_collection(self, name):
#     def find_by_id(self, _id, column=None):
#     def remove_by_id(self, _id):
#     def find_new_one(self, *args, **kwargs):
#     def get_as_dict(self, condition=None, column=None, skip=0, limit=0, sort=None):
#     def _valide_update_document(self, document):
#     def _valid_record(self, record):
#     def inc(self, spec_or_id, key, num=1):
#     def put(self, value, **kwargs):
#     def delete(self, _id):
#     def get(self, _id):
#     def read(self, _id):
#     def write_action_call(self, name, *args, **kwargs):
#     def read_action_call(self, name, *args, **kwargs):
# class MixinModel(object):
# class MongoTurboConnect(object):
# class AbstractModel(MixinModel):
#     PRIMARY_KEY_TYPE = ObjectId
# 
# Path: turbo/mongo_model.py
# class MixinModel(object):
# 
#     @staticmethod
#     def utctimestamp(seconds=None):
#         if seconds:
#             return long(time.mktime(time.gmtime(seconds)))
#         else:
#             return long(time.mktime(time.gmtime()))
# 
#     @staticmethod
#     def timestamp():
#         return long(time.time())
# 
#     @staticmethod
#     def datetime(dt=None):
#         if dt:
#             return datetime.strptime(dt, '%Y-%m-%d %H:%M')
#         else:
#             return datetime.now()
# 
#     @staticmethod
#     def utcdatetime(dt=None):
#         if dt:
#             return datetime.strptime(dt, '%Y-%m-%d %H:%M')
#         else:
#             return datetime.utcnow()
# 
#     @classmethod
#     def to_one_str(cls, value, *args, **kwargs):
#         """Convert single record's values to str
#         """
#         if kwargs.get('wrapper'):
#             return cls._wrapper_to_one_str(value)
# 
#         return _es.to_dict_str(value)
# 
#     @classmethod
#     def to_str(cls, values, callback=None):
#         """Convert many records's values to str
#         """
#         if callback and callable(callback):
#             if isinstance(values, dict):
#                 return callback(_es.to_str(values))
# 
#             return [callback(_es.to_str(i)) for i in values]
#         return _es.to_str(values)
# 
#     @staticmethod
#     @convert_to_record
#     def _wrapper_to_one_str(value):
#         return _es.to_dict_str(value)
# 
#     @staticmethod
#     def default_encode(v):
#         return _es.default_encode(v)
# 
#     @staticmethod
#     def json_encode(v):
#         return _es.json_encode(v)
# 
#     @staticmethod
#     def json_decode(v):
#         return _es.json_decode(v)
# 
#     @staticmethod
#     def to_objectid(objid):
#         return _es.to_objectid(objid)
# 
#     @staticmethod
#     def create_objectid():
#         """Create new objectid
#         """
#         return ObjectId()
# 
#     _instance = {}
# 
#     @classmethod
#     def instance(cls, name):
#         """Instantiate a model class according to import path
#         args:
#             name: class import path like `user.User`
#         return:
#             model instance
#         """
#         if not cls._instance.get(name):
#             model_name = name.split('.')
#             ins_name = '.'.join(
#                 ['models', model_name[0], 'model', model_name[1]])
#             cls._instance[name] = cls.import_model(ins_name)()
# 
#         return cls._instance[name]
# 
#     @classmethod
#     def import_model(cls, ins_name):
#         """Import model class in models package
#         """
#         try:
#             package_space = getattr(cls, 'package_space')
#         except AttributeError:
#             raise ValueError('package_space not exist')
#         else:
#             return import_object(ins_name, package_space)
# 
#     @staticmethod
#     def default_record():
#         """Generate one default record that return empty str when key not exist
#         """
#         return defaultdict(lambda: '')


import warnings
from bson.objectid import ObjectId
from pymongo import DESCENDING, collection
from turbo import mongo_model
from turbo.mongo_model import MixinModel  # noqa E401  compatibility for turbo below 0.4.5
# -*- coding:utf-8 -*-
from __future__ import (
    absolute_import,
    division,
    print_function,
    with_statement,

# Path: turbo/mongo_model.py
# def _record(x):
# def convert_to_record(func):
#     def wrapper(self, *args, **kwargs):
#     def utctimestamp(seconds=None):
#     def timestamp():
#     def datetime(dt=None):
#     def utcdatetime(dt=None):
#     def to_one_str(cls, value, *args, **kwargs):
#     def to_str(cls, values, callback=None):
#     def _wrapper_to_one_str(value):
#     def default_encode(v):
#     def json_encode(v):
#     def json_decode(v):
#     def to_objectid(objid):
#     def create_objectid():
#     def instance(cls, name):
#     def import_model(cls, ins_name):
#     def default_record():
# def collection_method_call(turbo_connect_ins, name):
#     def outwrapper(func):
#         def wrapper(*args, **kwargs):
#     def __init__(self, model_ins, db_collect=None):
#     def __getattr__(self, name):
#     def __getitem__(self, name):
#     def _init(self, db_name, _mongo_db_mapping):
#     def _to_primary_key(self, _id):
#     def __setitem__(self, k, v):
#     def __getitem__(self, k):
#     def __str__(self):
#     def sub_collection(self, name):
#     def find_by_id(self, _id, column=None):
#     def remove_by_id(self, _id):
#     def find_new_one(self, *args, **kwargs):
#     def get_as_dict(self, condition=None, column=None, skip=0, limit=0, sort=None):
#     def _valide_update_document(self, document):
#     def _valid_record(self, record):
#     def inc(self, spec_or_id, key, num=1):
#     def put(self, value, **kwargs):
#     def delete(self, _id):
#     def get(self, _id):
#     def read(self, _id):
#     def write_action_call(self, name, *args, **kwargs):
#     def read_action_call(self, name, *args, **kwargs):
# class MixinModel(object):
# class MongoTurboConnect(object):
# class AbstractModel(MixinModel):
#     PRIMARY_KEY_TYPE = ObjectId
# 
# Path: turbo/mongo_model.py
# class MixinModel(object):
# 
#     @staticmethod
#     def utctimestamp(seconds=None):
#         if seconds:
#             return long(time.mktime(time.gmtime(seconds)))
#         else:
#             return long(time.mktime(time.gmtime()))
# 
#     @staticmethod
#     def timestamp():
#         return long(time.time())
# 
#     @staticmethod
#     def datetime(dt=None):
#         if dt:
#             return datetime.strptime(dt, '%Y-%m-%d %H:%M')
#         else:
#             return datetime.now()
# 
#     @staticmethod
#     def utcdatetime(dt=None):
#         if dt:
#             return datetime.strptime(dt, '%Y-%m-%d %H:%M')
#         else:
#             return datetime.utcnow()
# 
#     @classmethod
#     def to_one_str(cls, value, *args, **kwargs):
#         """Convert single record's values to str
#         """
#         if kwargs.get('wrapper'):
#             return cls._wrapper_to_one_str(value)
# 
#         return _es.to_dict_str(value)
# 
#     @classmethod
#     def to_str(cls, values, callback=None):
#         """Convert many records's values to str
#         """
#         if callback and callable(callback):
#             if isinstance(values, dict):
#                 return callback(_es.to_str(values))
# 
#             return [callback(_es.to_str(i)) for i in values]
#         return _es.to_str(values)
# 
#     @staticmethod
#     @convert_to_record
#     def _wrapper_to_one_str(value):
#         return _es.to_dict_str(value)
# 
#     @staticmethod
#     def default_encode(v):
#         return _es.default_encode(v)
# 
#     @staticmethod
#     def json_encode(v):
#         return _es.json_encode(v)
# 
#     @staticmethod
#     def json_decode(v):
#         return _es.json_decode(v)
# 
#     @staticmethod
#     def to_objectid(objid):
#         return _es.to_objectid(objid)
# 
#     @staticmethod
#     def create_objectid():
#         """Create new objectid
#         """
#         return ObjectId()
# 
#     _instance = {}
# 
#     @classmethod
#     def instance(cls, name):
#         """Instantiate a model class according to import path
#         args:
#             name: class import path like `user.User`
#         return:
#             model instance
#         """
#         if not cls._instance.get(name):
#             model_name = name.split('.')
#             ins_name = '.'.join(
#                 ['models', model_name[0], 'model', model_name[1]])
#             cls._instance[name] = cls.import_model(ins_name)()
# 
#         return cls._instance[name]
# 
#     @classmethod
#     def import_model(cls, ins_name):
#         """Import model class in models package
#         """
#         try:
#             package_space = getattr(cls, 'package_space')
#         except AttributeError:
#             raise ValueError('package_space not exist')
#         else:
#             return import_object(ins_name, package_space)
# 
#     @staticmethod
#     def default_record():
#         """Generate one default record that return empty str when key not exist
#         """
#         return defaultdict(lambda: '')


# Path: turbo/model.py
import warnings
from bson.objectid import ObjectId
from pymongo import DESCENDING, collection
from turbo import mongo_model
from turbo.mongo_model import MixinModel  # noqa E401  compatibility for turbo below 0.4.5

# -*- coding:utf-8 -*-
from __future__ import (
    absolute_import,
    division,
    print_function,
    with_statement,

)