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


Python ICurrentDraftManagement.targetKey方法代碼示例

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


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

示例1: test_save

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
    def test_save(self):
        request = self.request
        response = request.response
        
        current = ICurrentDraftManagement(request)
        self.assertEquals(False, current.save())
        
        self.failIf('plone.app.drafts.targetKey' in response.cookies)
        self.failIf('plone.app.drafts.draftName' in response.cookies)
        self.failIf('plone.app.drafts.userId' in response.cookies)
        self.failIf('plone.app.drafts.path' in response.cookies)
        
        current.targetKey = u"123"
        self.assertEquals(True, current.save())
        
        self.assertEquals({'value': '123', 'quoted': True, 'path': '/'}, response.cookies['plone.app.drafts.targetKey'])
        self.failIf('plone.app.drafts.draftName' in response.cookies)
        self.failIf('plone.app.drafts.path' in response.cookies)
        
        current.targetKey = u"123"
        current.draftName = u"draft-1"
        self.assertEquals(True, current.save())
        
        self.assertEquals({'value': '123', 'quoted': True, 'path': '/'}, response.cookies['plone.app.drafts.targetKey'])
        self.assertEquals({'value': 'draft-1', 'quoted': True, 'path': '/'}, response.cookies['plone.app.drafts.draftName'])
        self.failIf('plone.app.drafts.path' in response.cookies)
        
        current.targetKey = u"123"
        current.draftName = u"draft-1"
        current.path = '/test'
        self.assertEquals(True, current.save())

        self.assertEquals({'value': '123', 'quoted': True, 'path': '/test'}, response.cookies['plone.app.drafts.targetKey'])
        self.assertEquals({'value': 'draft-1', 'quoted': True, 'path': '/test'}, response.cookies['plone.app.drafts.draftName'])
        self.assertEquals({'value': '/test', 'quoted': True, 'path': '/test'}, response.cookies['plone.app.drafts.path'])
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:37,代碼來源:tests.py

示例2: beginDrafting

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
def beginDrafting(context, event):
    """When we enter the edit screen, set up the target key and draft cookie
    path. If there is exactly one draft for the given user id and target key,
    consider that to be the current draft. Also mark the request with
    IDrafting if applicable.
    """

    storage = queryUtility(IDraftStorage)
    if storage is None or not storage.enabled:
        return

    request = getattr(context, 'REQUEST', None)
    if request is None:
        return

    current = ICurrentDraftManagement(request)

    # Update target key regardless - we could have a stale cookie
    current.targetKey = getObjectKey(context)

    if current.draftName is None:
        drafts = storage.getDrafts(current.userId, current.targetKey)
        if len(drafts) == 1:
            current.draftName = tuple(drafts.keys())[0]

    # Save the path now so that we can use it again later, even on URLs
    # (e.g. in AJAX dialogues) that are below this path.
    current.path = current.defaultPath

    current.mark()
    current.save()
開發者ID:plone,項目名稱:plone.app.drafts,代碼行數:33,代碼來源:lifecycle.py

示例3: test_mark

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
 def test_mark(self):
     request = self.request
     
     current = ICurrentDraftManagement(request)
     current.mark()
     self.failIf(IDrafting.providedBy(request))
     
     current.targetKey = u"123"
     current.mark()
     self.failUnless(IDrafting.providedBy(request))
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:12,代碼來源:tests.py

示例4: test_targetKey

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
 def test_targetKey(self):
     request = self.request
     
     current = ICurrentDraftManagement(request)
     self.assertEquals(None, current.targetKey)
     
     request.set('plone.app.drafts.targetKey', u"123")
     self.assertEquals(u"123", current.targetKey)
     
     current.targetKey = u"234"
     self.assertEquals(u"234", current.targetKey)
     
     self.assertEquals(u"123", request.get('plone.app.drafts.targetKey'))
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:15,代碼來源:tests.py

示例5: test_getCurrentDraft_draft_details_set_not_in_storage

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
 def test_getCurrentDraft_draft_details_set_not_in_storage(self):
     request = self.request
     
     management = ICurrentDraftManagement(request)
     management.userId = u"user1"
     management.targetKey = u"123"
     management.draftName = u"bogus"
     
     draft = getCurrentDraft(request)
     self.assertEquals(None, draft)
     
     response = request.response
     self.failIf('plone.app.drafts.targetKey' in response.cookies)
     self.failIf('plone.app.drafts.draftName' in response.cookies)
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:16,代碼來源:tests.py

示例6: test_getCurrentDraft_draft_details_set_in_storage_create

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
 def test_getCurrentDraft_draft_details_set_in_storage_create(self):
     request = self.request
     
     inStorage = getUtility(IDraftStorage).createDraft(u"user1", u"123")
     
     management = ICurrentDraftManagement(request)
     management.userId = u"user1"
     management.targetKey = u"123"
     management.draftName = inStorage.__name__
     
     draft = getCurrentDraft(request, create=True)
     self.assertEquals(inStorage, draft)
     
     response = request.response
     self.failIf('plone.app.drafts.targetKey' in response.cookies)
     self.failIf('plone.app.drafts.draftName' in response.cookies)
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:18,代碼來源:tests.py

示例7: test_getCurrentDraft_draft_details_set_not_in_storage_create

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
 def test_getCurrentDraft_draft_details_set_not_in_storage_create(self):
     request = self.request
     
     management = ICurrentDraftManagement(request)
     management.userId = u"user1"
     management.targetKey = u"123"
     management.draftName = u"bogus"
     
     draft = getCurrentDraft(request, create=True)
     inStorage = getUtility(IDraftStorage).getDraft(u"user1", u"123", draft.__name__)
     
     self.assertEquals(inStorage, draft)
     
     response = request.response
     self.failUnless('plone.app.drafts.targetKey' in response.cookies)
     self.failUnless('plone.app.drafts.draftName' in response.cookies)
     
     self.assertEquals('123', response.cookies['plone.app.drafts.targetKey']['value'])
     self.assertEquals(draft.__name__, response.cookies['plone.app.drafts.draftName']['value'])
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:21,代碼來源:tests.py

示例8: test_draft

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
 def test_draft(self):
     request = self.request
     
     current = ICurrentDraftManagement(request)
     self.assertEquals(None, current.draft)
     
     current.userId = u"user1"
     current.targetKey = u"123"
     current.draftName = u"draft"
     
     self.assertEquals(None, current.draft)
     
     storage = getUtility(IDraftStorage)
     created = storage.createDraft(u"user1", u"123")
     current.draftName = created.__name__
     
     self.assertEquals(created, current.draft)
     
     newDraft = storage.createDraft(u"user1", u"123")
     current.draft = newDraft
     
     self.assertEquals(newDraft, current.draft)
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:24,代碼來源:tests.py

示例9: _get_adapted_request

# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import targetKey [as 別名]
 def _get_adapted_request(self):
     # returns the adapted request for the draft stuff
     adapted_request = ICurrentDraftManagement(self.request, None)
     adapted_request.userId = getCurrentUserId()
     adapted_request.targetKey = getDefaultKey(self.context)
     return adapted_request
開發者ID:headnet,項目名稱:plone.formwidget.multifile,代碼行數:8,代碼來源:temporaryfile.py


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