vendor/Five/1.2b-r20590

view skin/standardmacros.py @ 0:3673ed425f80

Vendor import of Five 1.2b+ (r20590)
author fguillaume
date Fri, 02 Dec 2005 20:25:42 +0000
parents
children
line source
1 ##############################################################################
2 #
3 # Copyright (c) 2004, 2005 Zope Corporation and Contributors.
4 # All Rights Reserved.
5 #
6 # This software is subject to the provisions of the Zope Public License,
7 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11 # FOR A PARTICULAR PURPOSE.
12 #
13 ##############################################################################
14 """Mimick the Zope 3 skinning system in Five.
16 $Id: standardmacros.py 12884 2005-05-30 13:10:41Z philikon $
17 """
18 from zope.interface.common.mapping import IItemMapping
19 from zope.interface import implements
20 from zope.component import getView
21 from Products.Five.browser import BrowserView
23 # this is a verbatim copy of zope.app.basicskin except that it doesn't
24 # derive from ``object``
25 class Macros:
26 implements(IItemMapping)
28 macro_pages = ()
29 aliases = {
30 'view': 'page',
31 'dialog': 'page',
32 'addingdialog': 'page'
33 }
35 def __getitem__(self, key):
36 key = self.aliases.get(key, key)
37 context = self.context
38 request = self.request
39 for name in self.macro_pages:
40 page = getView(context, name, request)
41 try:
42 v = page[key]
43 except KeyError:
44 pass
45 else:
46 return v
47 raise KeyError, key
50 class StandardMacros(BrowserView, Macros):
51 macro_pages = ('five_template',
52 'widget_macros',
53 'form_macros',)