Example #1
0
 class SomeClass2(TableModel):
     __tablename__ = "%s_%d" % (fn, 2)
     i = Integer32(pk=True)
     a = Any(store_as='jsonb')
Example #2
0
    @rpc(_returns=Any)
    def plaintext(ctx):
        """Test 6: Plaintext"""
        ctx.out_protocol = outprot_plain
        return b"Hello, World!"


def _force_int(v):
    try:
        return min(500, max(int(v), 1))
    except:
        return 1


NumQueriesType = Any(sanitizer=_force_int)


class TfbOrmService(ServiceBase):
    @rpc(_returns=World)
    def db(ctx):
        retval = ctx.udc.session.query(World).get(randint(1, 10000))
        return retval

    @rpc(NumQueriesType, _returns=Array(World))
    def dbs(ctx, queries):
        if queries is None:
            queries = 1

        q = ctx.udc.session.query(World)
        return [q.get(randint(1, 10000)) for _ in xrange(queries)]