Back to index

plone3  3.1.7
utils.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """GenericSetup browser view utils.
00014 
00015 $Id: utils.py 40715 2005-12-12 10:33:40Z yuppie $
00016 """
00017 
00018 class AddWithPresettingsViewBase:
00019 
00020     """Base class for add views with selectable presettings.
00021     """
00022 
00023     def title(self):
00024         return u'Add %s' % self.klass.meta_type
00025 
00026     def __call__(self, add_input_name='', settings_id='', submit_add=''):
00027         if submit_add:
00028             obj = self.klass('temp')
00029             if settings_id:
00030                 ids = settings_id.split('/')
00031                 profile_id = ids[0]
00032                 obj_path = ids[1:]
00033                 if not add_input_name:
00034                     self.request.set('add_input_name', obj_path[-1])
00035                 self._initSettings(obj, profile_id, obj_path)
00036             self.context.add(obj)
00037             self.request.response.redirect(self.context.nextURL())
00038             return ''
00039         return self.index()