當前位置: 首頁>>代碼示例>>Python>>正文


Python DBSession.flush方法代碼示例

本文整理匯總了Python中por.models.DBSession.flush方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.flush方法的具體用法?Python DBSession.flush怎麽用?Python DBSession.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在por.models.DBSession的用法示例。


在下文中一共展示了DBSession.flush方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_add_primarykey_cr

# 需要導入模塊: from por.models import DBSession [as 別名]
# 或者: from por.models.DBSession import flush [as 別名]
 def test_add_primarykey_cr(self):
     session = DBSession()
     project1 = Project(name=u'My project 11')
     cr1 = CustomerRequest(name=u'My Customer reqeust 1')
     cr1.project = project1
     cr2 = CustomerRequest(name=u'My Customer reqeust 2')
     cr2.project = project1
     project2 = Project(name=u'My project 12')
     cr3 = CustomerRequest(name=u'My Customer reqeust 1')
     cr3.project = project2
     session.add(cr1)
     session.add(cr2)
     session.add(cr3)
     session.flush()
     self.assertTrue(cr1.id in ['my-project-11_2','my-project-11_1'])
     self.assertTrue(cr2.id in ['my-project-11_2','my-project-11_1'])
     self.assertEqual(cr3.id, 'my-project-12_1')
開發者ID:getpenelope,項目名稱:por.models,代碼行數:19,代碼來源:test_dashboard.py

示例2: TimeEntry

# 需要導入模塊: from por.models import DBSession [as 別名]
# 或者: from por.models.DBSession import flush [as 別名]
    if crstate_errors:
        return {
                'state': False,
                'message': '\n'.join(crstate_errors),
                }

    time_entry = TimeEntry(date = entry_date,
                           hours = entry_time_delta,
                           location = entry_location,
                           description = entry_description,
                           ticket = entry_ticket)
    time_entry.request = request        # bind for user lookup

    time_entry.project_id = entry_project
    session.add(time_entry)
    session.flush()

    return {
            'status': True,
            'message': u'Correctly added time entry %s for %s ticket #%s' % (time_entry.id, entry_project, entry_ticket),
            }



@jsonrpc_method(endpoint='DashboardAPI')
def create_new_advanced_time_entry(request, entry_ticket, entry_start, entry_end,
                                   entry_description, entry_location, entry_project):
    """
    Time entry creation: simple time entry case
    """
開發者ID:getpenelope,項目名稱:por.dashboard,代碼行數:32,代碼來源:api.py


注:本文中的por.models.DBSession.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。