当前位置: 首页>>代码示例>>Python>>正文


Python Registry.getDBAPIClass方法代码示例

本文整理汇总了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)
开发者ID:VoiSmart,项目名称:twistar,代码行数:14,代码来源:test_dbobject.py

示例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)
开发者ID:VoiSmart,项目名称:twistar,代码行数:15,代码来源:test_dbobject.py

示例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))
开发者ID:vik-singh,项目名称:inbox,代码行数:18,代码来源:inbox.py

示例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)
开发者ID:VoiSmart,项目名称:twistar,代码行数:20,代码来源:test_dbobject.py


注:本文中的twistar.registry.Registry.getDBAPIClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。