vendor/Five/1.2b-r20590

view tests/testing/simplecontent.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 """Simple content class(es) for browser tests
16 $Id: simplecontent.py 17809 2005-09-24 09:07:41Z efge $
17 """
18 from OFS.SimpleItem import SimpleItem
19 from Globals import InitializeClass
20 from AccessControl import ClassSecurityInfo
22 from zope.interface import Interface, implements
23 from Products.Five.traversable import Traversable
25 class ISimpleContent(Interface):
26 pass
28 class ICallableSimpleContent(ISimpleContent):
29 pass
31 class IIndexSimpleContent(ISimpleContent):
32 pass
34 class SimpleContent(Traversable, SimpleItem):
35 implements(ISimpleContent)
37 meta_type = 'Five SimpleContent'
38 security = ClassSecurityInfo()
40 afterAdd_called = False
41 beforeDelete_called = False
43 def __init__(self, id, title):
44 self.id = id
45 self.title = title
47 def manage_afterAdd(self, item, container):
48 self.afterAdd_called = True
50 def manage_beforeDelete(self, item, container):
51 self.beforeDelete_called = True
53 security.declarePublic('mymethod')
54 def mymethod(self):
55 return "Hello world"
57 security.declarePublic('direct')
58 def direct(self):
59 """Should be able to traverse directly to this as there is no view.
60 """
61 return "Direct traversal worked"
63 InitializeClass(SimpleContent)
65 class CallableSimpleContent(SimpleItem):
66 """A Viewable piece of content"""
67 implements(ICallableSimpleContent)
69 meta_type = "Five CallableSimpleContent"
71 def __call__(self, *args, **kw):
72 """ """
73 return "Default __call__ called"
75 InitializeClass(CallableSimpleContent)
77 class IndexSimpleContent(SimpleItem):
78 """A Viewable piece of content"""
79 implements(IIndexSimpleContent)
81 meta_type = 'Five IndexSimpleContent'
83 def index_html(self, *args, **kw):
84 """ """
85 return "Default index_html called"
87 InitializeClass(IndexSimpleContent)
89 def manage_addSimpleContent(self, id, title, REQUEST=None):
90 """Add the simple content."""
91 self._setObject(id, SimpleContent(id, title))
93 def manage_addCallableSimpleContent(self, id, title, REQUEST=None):
94 """Add the viewable simple content."""
95 self._setObject(id, CallableSimpleContent(id, title))
97 def manage_addIndexSimpleContent(self, id, title, REQUEST=None):
98 """Add the viewable simple content."""
99 self._setObject(id, IndexSimpleContent(id, title))