Beispiel #1
0
 def _init_fields(cls, model, valuedict):
     """ Initialize all fields defined for the model's class by
         assigning them their attribute names as names and putting their
         default values into valuedict.
     """
     modelcls = type(model)
     for name in (n for n in dir(modelcls) if not n.startswith('__')):
         field = getattr(modelcls, name)
         if not isinstance(field, Model.Field):
             continue
         if not getattr(field, 'name', None):
             field.name = name
         default = field.default
         value = default(model) if callable(default) else default
         valuedict[name] = value
Beispiel #2
0
 def _init_fields(cls, model, valuedict):
     """ Initialize all fields defined for the model's class by
         assigning them their attribute names as names and putting their
         default values into valuedict.
     """
     modelcls = type(model)
     for name in (n for n in dir(modelcls) if not n.startswith('__')):
         field = getattr(modelcls, name)
         if not isinstance(field, Model.Field):
             continue
         if not getattr(field, 'name', None):
             field.name = name
         default = field.default
         value = default(model) if callable(default) else default
         valuedict[name] = value
 def _validator(cls, valid):
     if callable(valid):
         return valid
     if not valid:
         return lambda _: True
     return cls._regexvalidator(valid)
Beispiel #4
0
 def _validator(cls, valid):
     if callable(valid):
         return valid
     if not valid:
         return lambda _: True
     return cls._regexvalidator(valid)
Beispiel #5
0
def _import_migration(modulename):
    qualname = 'cherrymusicserver.migrations.' + modulename
    mig = __import__(qualname, fromlist='dummy')
    if not callable(getattr(mig, 'migrate', None)):
        raise TypeError('Migration needs a `migrate` function: ' + mig.__name__)
    return mig