def test_changed_security_sets_priviledged_user_and_restores_old(self): self.assertEqual(self.test_user, api.user.get_current()) with changed_security(): self.assertEqual( SpecialUsers.system.getUserName(), api.user.get_current().getUserName()) self.assertEqual(self.test_user, api.user.get_current())
def store_in_yearfolder(self): """Move the forwarding (adapted context) in the actual yearfolder.""" inbox = aq_parent(aq_inner(self.context)) yearfolder = get_current_yearfolder(inbox=inbox) self.context.REQUEST.set(DISABLE_DOCPROPERTY_UPDATE_FLAG, True) with changed_security(): clipboard = inbox.manage_cutObjects((self.context.getId(),)) yearfolder.manage_pasteObjects(clipboard)
def _create_yearfolder(inbox, year): """creates the yearfolder for the given year""" with changed_security(): # for creating the folder, we need to be a superuser since # normal user should not be able to add year folders. # --- help i18ndude --- msg = _(u'yearfolder_title', default=u'Closed ${year}', mapping=dict(year=str(year))) # --- / help i18ndude --- folder_title = translate(str(msg), msg.domain, msg.mapping, context=inbox.REQUEST, default=msg.default) return createContentInContainer( inbox, 'opengever.inbox.yearfolder', title=folder_title, id=year)