本文整理汇总了Python中twistar.registry.Registry.getDBAPIClass方法的典型用法代码示例。如果您正苦于以下问题:Python Registry.getDBAPIClass方法的具体用法?Python Registry.getDBAPIClass怎么用?Python Registry.getDBAPIClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twistar.registry.Registry
的用法示例。
在下文中一共展示了Registry.getDBAPIClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_refresh
# 需要导入模块: from twistar.registry import Registry [as 别名]
# 或者: from twistar.registry.Registry import getDBAPIClass [as 别名]
def test_refresh(self):
dateklass = Registry.getDBAPIClass("Date")
args = {'first_name': "a", "last_name": "b", "age": 10}
u = yield User(**args).save()
# mess up the props, then refresh
u.first_name = "something different"
u.last_name = "another thing"
yield u.refresh()
for key, value in args.items():
self.assertEqual(getattr(u, key), value)
示例2: test_update
# 需要导入模块: from twistar.registry import Registry [as 别名]
# 或者: from twistar.registry.Registry import getDBAPIClass [as 别名]
def test_update(self):
dateklass = Registry.getDBAPIClass("Date")
args = {'first_name': "a", "last_name": "b", "age": 10}
u = yield User(**args).save()
args = {'first_name': "b", "last_name": "a", "age": 100}
for key, value in args.items():
setattr(u, key, value)
yield u.save()
u = yield User.find(u.id)
for key, value in args.items():
self.assertEqual(getattr(u, key), value)
示例3: sendMessage
# 需要导入模块: from twistar.registry import Registry [as 别名]
# 或者: from twistar.registry.Registry import getDBAPIClass [as 别名]
def sendMessage(subject, body, sender_id, receiver_id):
now = datetime.now()
Timestamp = Registry.getDBAPIClass("Timestamp")
# save message to datastore
message = Message(
subject=subject,
body=body,
sender_id=sender_id,
receiver_id=receiver_id,
sent_at=Timestamp(now.year, now.month, now.day, now.hour, now.minute, now.second)
)
message.save()
# js client is subscribed to topic with name inbox_user_<user_id> so it will publish to their list
self.publish('com.vik.inbox_user_' + str(message.receiver_id), formatMessage(message))
示例4: test_creation
# 需要导入模块: from twistar.registry import Registry [as 别名]
# 或者: from twistar.registry.Registry import getDBAPIClass [as 别名]
def test_creation(self):
# test creating blank object
u = yield User().save()
self.assertTrue(type(u.id) == int or type(u.id) == long)
# test creating object with props that don't correspond to columns
u = yield User(a_fake_column="blech").save()
self.assertTrue(type(u.id) == int or type(u.id) == long)
# Test table doesn't exist
f = FakeObject(blah = "something")
self.failUnlessFailure(f.save(), ImaginaryTableError)
dateklass = Registry.getDBAPIClass("Date")
args = {'first_name': "a", "last_name": "b", "age": 10, "dob": dateklass(2000, 1, 1)}
u = yield User(**args).save()
for key, value in args.items():
self.assertEqual(getattr(u, key), value)