Beispiel #1
0
    def __init__(cls, name, bases, dict):
        super(ModelMeta, cls).__init__(name, bases, dict)
        # Make sure this is a subclass of Model - mainly copied from django ModelBase (thanks!)
        cls.__sub_classes__ = []

        # Do a delayed import to prevent possible circular import errors.
        from boto.sdb.db.manager import get_manager

        try:
            if filter(lambda b: issubclass(b, Model), bases):
                for base in bases:
                    base.__sub_classes__.append(cls)
                cls._manager = get_manager(cls)
                # look for all of the Properties and set their names
                for key in dict.keys():
                    if isinstance(dict[key], Property):
                        property = dict[key]
                        property.__property_config__(cls, key)
                prop_names = []
                props = cls.properties()
                for prop in props:
                    if not prop.__class__.__name__.startswith('_'):
                        prop_names.append(prop.name)
                setattr(cls, '_prop_names', prop_names)
        except NameError:
            # 'Model' isn't defined yet, meaning we're looking at our own
            # Model class, defined below.
            pass
Beispiel #2
0
Datei: model.py Projekt: 10sr/hue
    def __init__(cls, name, bases, dict):
        super(ModelMeta, cls).__init__(name, bases, dict)
        # Make sure this is a subclass of Model - mainly copied from django ModelBase (thanks!)
        cls.__sub_classes__ = []

        # Do a delayed import to prevent possible circular import errors.
        from boto.sdb.db.manager import get_manager

        try:
            if filter(lambda b: issubclass(b, Model), bases):
                for base in bases:
                    base.__sub_classes__.append(cls)
                cls._manager = get_manager(cls)
                # look for all of the Properties and set their names
                for key in dict.keys():
                    if isinstance(dict[key], Property):
                        property = dict[key]
                        property.__property_config__(cls, key)
                prop_names = []
                props = cls.properties()
                for prop in props:
                    if not prop.__class__.__name__.startswith('_'):
                        prop_names.append(prop.name)
                setattr(cls, '_prop_names', prop_names)
        except NameError:
            # 'Model' isn't defined yet, meaning we're looking at our own
            # Model class, defined below.
            pass
Beispiel #3
0
 def __init__(cls, name, bases, dict):
     super(ModelMeta, cls).__init__(name, bases, dict)
     # Make sure this is a subclass of Model - mainly copied from django ModelBase (thanks!)
     cls.__sub_classes__ = []
     try:
         if [b for b in bases if issubclass(b, Model)]:
             for base in bases:
                 base.__sub_classes__.append(cls)
             cls._manager = get_manager(cls)
             # look for all of the Properties and set their names
             for key in list(dict.keys()):
                 if isinstance(dict[key], Property):
                     property = dict[key]
                     property.__property_config__(cls, key)
             prop_names = []
             props = cls.properties()
             for prop in props:
                 if not prop.__class__.__name__.startswith('_'):
                     prop_names.append(prop.name)
             setattr(cls, '_prop_names', prop_names)
     except NameError:
         # 'Model' isn't defined yet, meaning we're looking at our own
         # Model class, defined below.
         pass