Esempio n. 1
0
    def handle_submit(self, converted):
        if lock.owns_lock(self.context, self.userid):
            lock.clear(self.context)

        context = self.context
        request = self.request
        workflow = self.workflow
        # *will be* modified event
        objectEventNotify(ObjectWillBeModifiedEvent(context))
        if workflow is not None:
            if 'security_state' in converted:
                workflow.transition_to_state(context, request,
                                             converted['security_state'])

        context.text = converted['text']
        context.description = extract_description(converted['text'])
        newtitle = converted['title']
        if newtitle != context.title:
            context.change_title(newtitle)

        # Save the tags on it
        set_tags(context, request, converted['tags'])

        # Modified
        context.modified_by = authenticated_userid(request)
        objectEventNotify(ObjectModifiedEvent(context))

        location = model_url(context, request)
        msg = "?status_message=Wiki%20Page%20edited"
        return HTTPFound(location=location+msg)
Esempio n. 2
0
    def handle_submit(self, converted):
        if lock.owns_lock(self.context, self.userid):
            lock.clear(self.context)

        context = self.context
        request = self.request
        workflow = self.workflow
        # *will be* modified event
        objectEventNotify(ObjectWillBeModifiedEvent(context))
        if workflow is not None:
            if 'security_state' in converted:
                workflow.transition_to_state(context, request,
                                             converted['security_state'])

        context.text = converted['text']
        context.description = extract_description(converted['text'])
        newtitle = converted['title']
        if newtitle != context.title:
            context.change_title(newtitle)

        # Save the tags on it
        set_tags(context, request, converted['tags'])

        # Modified
        context.modified_by = authenticated_userid(request)
        objectEventNotify(ObjectModifiedEvent(context))

        location = resource_url(context, request)
        msg = "?status_message=Wiki%20Page%20edited"
        return HTTPFound(location=location + msg)
Esempio n. 3
0
def unlock_wiki_view(context, request, userid=None):
    if request.method.lower() == 'post':
        if userid is None:
            # for unit tests to override
            userid = authenticated_userid(request)
        if lock.owns_lock(context, userid):
            lock.clear(context)
        return HTTPOk(body='')
    return HTTPFound(location=resource_url(context, request))
Esempio n. 4
0
def unlock_wiki_view(context, request, userid=None):
    if request.method.lower() == 'post':
        if userid is None:
            # for unit tests to override
            userid = authenticated_userid(request)
        if lock.owns_lock(context, userid):
            lock.clear(context)
        return HTTPOk(body='')
    return HTTPFound(location=model_url(context, request))
Esempio n. 5
0
 def handle_cancel(self):
     if lock.owns_lock(self.context, self.userid):
         lock.clear(self.context)
     return HTTPFound(location=resource_url(self.context, self.request))
Esempio n. 6
0
 def handle_cancel(self):
     if lock.owns_lock(self.context, self.userid):
         lock.clear(self.context)
     return HTTPFound(location=model_url(self.context, self.request))
Esempio n. 7
0
 def test_lock_owner(self):
     context = karltesting.DummyModel()
     from karl.utilities import lock
     lock.lock(context, 'foo')
     self.failUnless(lock.owns_lock(context, 'foo'))
     self.failIf(lock.owns_lock(context, 'bar'))
Esempio n. 8
0
 def test_lock_owner(self):
     context = karltesting.DummyModel()
     from karl.utilities import lock
     lock.lock(context, 'foo')
     self.failUnless(lock.owns_lock(context, 'foo'))
     self.failIf(lock.owns_lock(context, 'bar'))