Back to index

plone3  3.1.7
helpers.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2004, 2005 Zope Corporation and Contributors.
00004 # All Rights Reserved.
00005 #
00006 # This software is subject to the provisions of the Zope Public License,
00007 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00008 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00009 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00010 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00011 # FOR A PARTICULAR PURPOSE.
00012 #
00013 ##############################################################################
00014 """Test helpers
00015 
00016 $Id: helpers.py 12915 2005-05-31 10:23:19Z philikon $
00017 """
00018 import urllib
00019 
00020 def add_and_edit(self, id, REQUEST):
00021     """Helper function to point to the object's management screen if
00022     'Add and Edit' button is pressed.
00023     id -- id of the object we just added
00024     """
00025     if REQUEST is None:
00026         return
00027     try:
00028         u = self.DestinationURL()
00029     except:
00030         u = REQUEST['URL1']
00031     if REQUEST.has_key('submit_edit'):
00032         u = "%s/%s" % (u, urllib.quote(id))
00033     REQUEST.RESPONSE.redirect(u+'/manage_main')
00034 
00035 
00036 from OFS.Folder import Folder
00037 
00038 class NoVerifyPasteFolder(Folder):
00039     """Folder that does not perform paste verification.
00040     Used by test_events
00041     """
00042     def _verifyObjectPaste(self, object, validate_src=1):
00043         pass
00044 
00045 def manage_addNoVerifyPasteFolder(container, id, title=''):
00046     container._setObject(id, NoVerifyPasteFolder())
00047     folder = container[id]
00048     folder.id = id
00049     folder.title = title
00050 
00051 class FiveTraversableFolder(Folder):
00052     """Folder that is declared Five traversable, see configure.zcml
00053     """
00054     pass
00055 
00056 def manage_addFiveTraversableFolder(container, id, title=''):
00057     container._setObject(id, FiveTraversableFolder())
00058     folder = container[id]
00059     folder.id = id
00060     folder.title = title
00061