示例#1
0
def deferred_class_factory(model, attrs):
    """
    Returns a class object that is a copy of "model" with the specified "attrs"
    being replaced with DeferredAttribute objects. The "pk_value" ties the
    deferred attributes to a particular instance of the model.
    """
    class Meta:
        pass
    setattr(Meta, "proxy", True)
    setattr(Meta, "app_label", model._meta.app_label)

    # The app_cache wants a unique name for each model, otherwise the new class
    # won't be created (we get an old one back). Therefore, we generate the
    # name using the passed in attrs. It's OK to reuse an old case if the attrs
    # are identical.
    name = "%s_Deferred_%s" % (model.__name__, '_'.join(sorted(list(attrs))))

    overrides = dict([(attr, DeferredAttribute(attr, model))
            for attr in attrs])
    overrides["Meta"] = Meta
    overrides["__module__"] = model.__module__
    overrides["_deferred"] = True
    return type(name, (model,), overrides)
示例#2
0
 def handle(self, *labels, **options):
     print 'EXECUTE:BaseCommand labels=%s, options=%s' % (labels, sorted(options.items()))
示例#3
0
 def handle(self, *labels, **options):
     print 'EXECUTE:BaseCommand labels=%s, options=%s' % (
         labels, sorted(options.items()))
示例#4
0
 def handle_app(self, app, **options):
     print 'EXECUTE:AppCommand app=%s, options=%s' % (
         app, sorted(options.items()))
示例#5
0
 def handle_label(self, label, **options):
     print('EXECUTE:LabelCommand label=%s, options=%s' % (label, sorted(options.items())))
示例#6
0
 def handle_noargs(self, **options):
     print 'EXECUTE:NoArgsCommand options=%s' % sorted(options.items())
示例#7
0
 def handle_app(self, app, **options):
     print 'EXECUTE:AppCommand app=%s, options=%s' % (app, sorted(options.items()))
示例#8
0
 def handle_noargs(self, **options):
     print 'EXECUTE:NoArgsCommand options=%s' % sorted(options.items())
示例#9
0
 def handle_label(self, label, **options):
     print 'EXECUTE:LabelCommand label=%s, options=%s' % (
         label, sorted(options.items()))