# Path: doodle/common/errors.py
# class PropertyError(BaseError):
#     pass
# 
# Path: doodle/core/property.py
# class BooleanProperty(Property):
#     def validate(self, value):
#         if value is not None:
#             return bool(value)
# 
# class IntegerProperty(Property):
#     def validate(self, value):
#         if value is not None:
#             try:
#                 return int(value)
#             except ValueError:
#                 raise ValueError('Property %s must be an int or long, not a %s'
#                                  % (self.name, value.__class__.__name__))
# 
# class PropertiedClass(type):
#     def __init__(cls, name, bases, dct):
#         super(PropertiedClass, cls).__init__(name, bases, dct)
# 
#         if 'KEY' not in cls.__dict__:
#             cls.KEY = cls.__name__
# 
#         if hasattr(cls, '_properties'):
#             cls._properties = cls._properties.copy()
#         else:
#             cls._properties = {}  # stores Property instances
# 
#         for prop_name, prop in dct.iteritems():
#             if isinstance(prop, Property):
#                 cls._properties[prop_name] = prop
#                 prop.name = prop_name
# 
# Path: doodle/core/redis_client.py



import logging
import json
from redis.client import Pipeline
from doodle.common.errors import PropertyError
from doodle.core.property import BooleanProperty, IntegerProperty, PropertiedClass
from doodle.core.redis_client import redis_main_client
    def __get__(self, obj, objtype=None):
        if objtype:
            return objtype.__name__


class SimpleModel(object):
    KEY = ClassName()  # won't work for grandchild class if changed by child class
    redis_client = redis_main_client


class PropertiedModel(SimpleModel):
    __metaclass__ = PropertiedClass

    def __init__(self, **kwargs):
        super(PropertiedModel, self).__init__()
        self._attributes = {}  # stores real values

        for attr_name in self._properties.iterkeys():
            attr_value = kwargs.get(attr_name)
            setattr(self, attr_name, attr_value)

    def to_dict(self):
        return self._attributes.copy()

    def __eq__(self, other):
        if type(self) is type(other) and self._attributes == other._attributes:
            return True
        return False



# Path: doodle/common/errors.py
# class PropertyError(BaseError):
#     pass
# 
# Path: doodle/core/property.py
# class BooleanProperty(Property):
#     def validate(self, value):
#         if value is not None:
#             return bool(value)
# 
# class IntegerProperty(Property):
#     def validate(self, value):
#         if value is not None:
#             try:
#                 return int(value)
#             except ValueError:
#                 raise ValueError('Property %s must be an int or long, not a %s'
#                                  % (self.name, value.__class__.__name__))
# 
# class PropertiedClass(type):
#     def __init__(cls, name, bases, dct):
#         super(PropertiedClass, cls).__init__(name, bases, dct)
# 
#         if 'KEY' not in cls.__dict__:
#             cls.KEY = cls.__name__
# 
#         if hasattr(cls, '_properties'):
#             cls._properties = cls._properties.copy()
#         else:
#             cls._properties = {}  # stores Property instances
# 
#         for prop_name, prop in dct.iteritems():
#             if isinstance(prop, Property):
#                 cls._properties[prop_name] = prop
#                 prop.name = prop_name
# 
# Path: doodle/core/redis_client.py



# Path: doodle/core/models/base_model.py
import logging
import json
from redis.client import Pipeline
from doodle.common.errors import PropertyError
from doodle.core.property import BooleanProperty, IntegerProperty, PropertiedClass
from doodle.core.redis_client import redis_main_client

    def __get__(self, obj, objtype=None):
        if objtype:
            return objtype.__name__


class SimpleModel(object):
    KEY = ClassName()  # won't work for grandchild class if changed by child class
    redis_client = redis_main_client


class PropertiedModel(SimpleModel):
    __metaclass__ = PropertiedClass

    def __init__(self, **kwargs):
        super(PropertiedModel, self).__init__()
        self._attributes = {}  # stores real values

        for attr_name in self._properties.iterkeys():
            attr_value = kwargs.get(attr_name)
            setattr(self, attr_name, attr_value)

    def to_dict(self):
        return self._attributes.copy()

    def __eq__(self, other):
        if type(self) is type(other) and self._attributes == other._attributes:
            return True
        return False



class JSONModel(PropertiedModel):