示例#1
0
class Bike(model.RedisModel):
    database = test_database
    namespace = 'database-contrib-tests'

    name = fields.StringField(indexable=True)
    wheels = fields.StringField(default=2)
    passengers = fields.StringField(default=1, cacheable=False)
示例#2
0
class Boat(TestRedisModel):
    """
    Use also InstanceHashField.
    """

    name = fields.StringField(unique=True)
    power = fields.InstanceHashField(indexable=True, default="sail")
    launched = fields.StringField(indexable=True)
    length = fields.StringField()
示例#3
0
class Boat(TestRedisModel):
    """
    Use also HashableField.
    """
    cacheable = False

    name = fields.StringField(unique=True)
    power = fields.HashableField(indexable=True, default="sail")
    launched = fields.StringField(indexable=True)
    length = fields.StringField()
示例#4
0
class MyJob(Job):
    """
    A job that will use Person's PK as identifier, and will store results of
    callback in a new field
    """
    result = fields.StringField()  # to store the result of the task
    queue_model = MyQueue
    queue_name = QUEUE_NAME

    start = fields.InstanceHashField(indexable=True)

    def get_object(self):
        """
        Return the object concerned by the current job's identifier
        """
        return Person.get(self.identifier.hget())

    def run(self, queue):
        """
        Create the fullname, and store a a message serving as result in the job
        """
        # add some random time to simulate a long job
        time.sleep(random.random())

        # compute the fullname
        obj = self.get_object()
        obj.fullname.hset('%s %s' % tuple(obj.hmget('firstname', 'lastname')))

        # this will the "result" of the job
        result = 'Created fullname for Person %s: %s' % (obj.pk.get(),
                                                         obj.fullname.hget())

        # save the result of the callback in the job itself
        self.result.set(result)

        # return the result for future use in the worker
        return result
示例#5
0
 class ThreadableModel(model.RedisModel):
     database = db1
     foo = fields.StringField()
示例#6
0
class Bike(TestRedisModel):
    name = fields.StringField(indexable=True)
    wheels = fields.StringField(default=2)
    passengers = fields.StringField(default=1)
示例#7
0
 class Bike2(TestRedisModel):
     name = fields.StringField()
     namespace = 'sub-tests'
示例#8
0
 class Bike5(six.with_metaclass(TestMetaClass, TestRedisModel)):
     name = fields.StringField()
     namespace = 'sub-tests2'
示例#9
0
 class Person(TestRedisModel):
     namespace = 'collection'
     id = fields.AutoPKField()
     name = fields.StringField(indexable=True)
示例#10
0
 class M(RelatedModel):
     namespace = 'transfert-db-relations'
     abstract = True
     foo = fields.StringField()
示例#11
0
 class MultiIndexTestModel(TestRedisModel):
     name = fields.StringField(indexable=True,
                               indexes=[index_class],
                               unique=True)
示例#12
0
 class Train(TestRedisModel):
     namespace = "test_stringfield_keys_are_deleted"
     name = fields.StringField(unique=True)
     kind = fields.StringField(indexable=True)
     wagons = fields.StringField(default=10)
示例#13
0
 class ExtendedError(Error):
     namespace = 'test-errortests'
     foo = fields.StringField()
     bar = fields.StringField()
示例#14
0
 class ExtendedJob(Job):
     namespace = 'test-jobstest'
     foo = fields.StringField()
     bar = fields.StringField()
示例#15
0
class Ferry(TestRedisModel):
    name = fields.StringField(unique=True)
示例#16
0
class Vegetable(TestRedisModel):
    name = fields.StringField(indexable=True)
    color = fields.StringField()
    pip = fields.StringField(indexable=True)
示例#17
0
class MotorBike(Bike):
    power = fields.StringField()
示例#18
0
class Person(TestRedisModel):
    name = fields.PKField()
    age = fields.StringField(indexable=True)
    prefered_group = FKStringField('Group')
    following = M2MSetField('self', related_name='followers')
示例#19
0
 class ExtendedQueue(Queue):
     namespace = 'test-queuestest'
     foo = fields.StringField()
     bar = fields.StringField()
示例#20
0
 class Bike6(
         future.utils.with_metaclass(TestMetaClass,
                                     TestRedisModel)):
     name = fields.StringField()
     namespace = 'sub-tests2'
示例#21
0
 class Train(TestRedisModel):
     namespace = "test_model_delete"
     name = fields.InstanceHashField(unique=True)
     kind = fields.StringField(indexable=True)
     wagons = fields.InstanceHashField(default=10)
示例#22
0
 class AutoPkModel(TestRedisModel):
     name = fields.StringField(indexable=True)
示例#23
0
class Group(TestRedisModel):
    name = fields.PKField()
    status = fields.StringField(indexable=True)
    owner = FKInstanceHashField(Person, related_name='owned_groups')
    parent = FKStringField('self', related_name='children')
    members = M2MSetField(Person, related_name='membership')
示例#24
0
 class NotAutoPkModel(TestRedisModel):
     pk = fields.PKField()
     name = fields.StringField(indexable=True)
示例#25
0
 class WithoutDB(model.RedisModel):
     name = fields.StringField()
示例#26
0
 class Bike(TestRedisModel):
     name = fields.StringField()
示例#27
0
 class MyEmail(TestRedisModel):
     subject = fields.StringField(indexable=True)
     headers = fields.HashField(indexable=True)
示例#28
0
 class Bike3(TestRedisModel):
     __metaclass__ = TestMetaClass
     name = fields.StringField()
     namespace = 'sub-tests2'