Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
1534f218
Commit
1534f218
authored
Jun 01, 2005
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Plain Diff
Merge r30591 from the trunk:
Update Five to release 1.0.1.
parents
3fe671ef
605924f7
Changes
56
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
56 changed files
with
963 additions
and
202 deletions
+963
-202
lib/python/Products/Five/CHANGES.txt
lib/python/Products/Five/CHANGES.txt
+35
-2
lib/python/Products/Five/CREDITS.txt
lib/python/Products/Five/CREDITS.txt
+2
-0
lib/python/Products/Five/README.txt
lib/python/Products/Five/README.txt
+1
-1
lib/python/Products/Five/ReuseUtils.py
lib/python/Products/Five/ReuseUtils.py
+6
-1
lib/python/Products/Five/TrustedExpression.py
lib/python/Products/Five/TrustedExpression.py
+5
-1
lib/python/Products/Five/__init__.py
lib/python/Products/Five/__init__.py
+3
-2
lib/python/Products/Five/adding.py
lib/python/Products/Five/adding.py
+27
-10
lib/python/Products/Five/bridge.py
lib/python/Products/Five/bridge.py
+3
-3
lib/python/Products/Five/browser.py
lib/python/Products/Five/browser.py
+40
-4
lib/python/Products/Five/browserconfigure.py
lib/python/Products/Five/browserconfigure.py
+3
-2
lib/python/Products/Five/configure.zcml
lib/python/Products/Five/configure.zcml
+1
-0
lib/python/Products/Five/doc/main.txt
lib/python/Products/Five/doc/main.txt
+6
-2
lib/python/Products/Five/edit.pt
lib/python/Products/Five/edit.pt
+9
-6
lib/python/Products/Five/eventconfigure.py
lib/python/Products/Five/eventconfigure.py
+3
-3
lib/python/Products/Five/fiveconfigure.py
lib/python/Products/Five/fiveconfigure.py
+3
-2
lib/python/Products/Five/fivedirectives.py
lib/python/Products/Five/fivedirectives.py
+3
-2
lib/python/Products/Five/i18n.zcml
lib/python/Products/Five/i18n.zcml
+9
-0
lib/python/Products/Five/interfaces.py
lib/python/Products/Five/interfaces.py
+2
-4
lib/python/Products/Five/metaclass.py
lib/python/Products/Five/metaclass.py
+2
-1
lib/python/Products/Five/metaconfigure.py
lib/python/Products/Five/metaconfigure.py
+3
-2
lib/python/Products/Five/pagetemplatefile.py
lib/python/Products/Five/pagetemplatefile.py
+5
-2
lib/python/Products/Five/resource.py
lib/python/Products/Five/resource.py
+2
-2
lib/python/Products/Five/security.py
lib/python/Products/Five/security.py
+3
-2
lib/python/Products/Five/sizeconfigure.py
lib/python/Products/Five/sizeconfigure.py
+3
-2
lib/python/Products/Five/skin.py
lib/python/Products/Five/skin.py
+3
-2
lib/python/Products/Five/tests/__init__.py
lib/python/Products/Five/tests/__init__.py
+1
-12
lib/python/Products/Five/tests/adding.txt
lib/python/Products/Five/tests/adding.txt
+54
-0
lib/python/Products/Five/tests/dummy.py
lib/python/Products/Five/tests/dummy.py
+6
-1
lib/python/Products/Five/tests/fivetest.py
lib/python/Products/Five/tests/fivetest.py
+5
-1
lib/python/Products/Five/tests/forms.txt
lib/python/Products/Five/tests/forms.txt
+427
-0
lib/python/Products/Five/tests/products/FiveTest/__init__.py
lib/python/Products/Five/tests/products/FiveTest/__init__.py
+0
-13
lib/python/Products/Five/tests/products/FiveTest/browser.py
lib/python/Products/Five/tests/products/FiveTest/browser.py
+6
-1
lib/python/Products/Five/tests/products/FiveTest/classes.py
lib/python/Products/Five/tests/products/FiveTest/classes.py
+5
-1
lib/python/Products/Five/tests/products/FiveTest/configure.zcml
...thon/Products/Five/tests/products/FiveTest/configure.zcml
+1
-1
lib/python/Products/Five/tests/products/FiveTest/fancycontent.py
...hon/Products/Five/tests/products/FiveTest/fancycontent.py
+6
-1
lib/python/Products/Five/tests/products/FiveTest/helpers.py
lib/python/Products/Five/tests/products/FiveTest/helpers.py
+5
-1
lib/python/Products/Five/tests/products/FiveTest/interfaces.py
...ython/Products/Five/tests/products/FiveTest/interfaces.py
+26
-7
lib/python/Products/Five/tests/products/FiveTest/metaconfigure.py
...on/Products/Five/tests/products/FiveTest/metaconfigure.py
+2
-2
lib/python/Products/Five/tests/products/FiveTest/schemacontent.py
...on/Products/Five/tests/products/FiveTest/schemacontent.py
+17
-0
lib/python/Products/Five/tests/products/FiveTest/simplecontent.py
...on/Products/Five/tests/products/FiveTest/simplecontent.py
+5
-1
lib/python/Products/Five/tests/products/FiveTest/size.py
lib/python/Products/Five/tests/products/FiveTest/size.py
+17
-0
lib/python/Products/Five/tests/products/FiveTest/subscriber.py
...ython/Products/Five/tests/products/FiveTest/subscriber.py
+5
-1
lib/python/Products/Five/tests/runalltests.py
lib/python/Products/Five/tests/runalltests.py
+0
-12
lib/python/Products/Five/tests/test_adding.py
lib/python/Products/Five/tests/test_adding.py
+30
-0
lib/python/Products/Five/tests/test_bridge.py
lib/python/Products/Five/tests/test_bridge.py
+2
-1
lib/python/Products/Five/tests/test_editform.py
lib/python/Products/Five/tests/test_editform.py
+42
-65
lib/python/Products/Five/tests/test_event.py
lib/python/Products/Five/tests/test_event.py
+8
-5
lib/python/Products/Five/tests/test_five.py
lib/python/Products/Five/tests/test_five.py
+6
-1
lib/python/Products/Five/tests/test_security.py
lib/python/Products/Five/tests/test_security.py
+6
-1
lib/python/Products/Five/tests/test_security2.py
lib/python/Products/Five/tests/test_security2.py
+7
-2
lib/python/Products/Five/tests/test_viewable.py
lib/python/Products/Five/tests/test_viewable.py
+74
-0
lib/python/Products/Five/tests/zopeconf.py
lib/python/Products/Five/tests/zopeconf.py
+6
-3
lib/python/Products/Five/traversable.py
lib/python/Products/Five/traversable.py
+3
-2
lib/python/Products/Five/version.txt
lib/python/Products/Five/version.txt
+1
-1
lib/python/Products/Five/viewable.py
lib/python/Products/Five/viewable.py
+5
-6
lib/python/Products/Five/zcml.py
lib/python/Products/Five/zcml.py
+3
-2
No files found.
lib/python/Products/Five/CHANGES.txt
View file @
1534f218
...
...
@@ -2,11 +2,44 @@
Five Changes
============
Five 1.0
(2005-04-27
)
=====================
Five 1.0
.1 (2005-05-31
)
=====================
==
This version is also included in Zope 2.8.
* Changed license headers to the ones used in the Zope.org repository.
This makes merging between the main development line of Five (hosted
on codespeak.net) and the version integrated into Zope 2.8 much
easier. The actual copyright ownership isn't affected because Five
had been contributed to the Zope project anyway (which was blessed
by all Five contributors).
* Made automatically generated add and edit forms unicode-aware.
ZPublisher does not automatically decode incoming form values to
unicode, so AddView and EditView emulate this behaviour themselves
now. They also take care of setting the right charset on the
outgoing form so that ZPublisher will encode it accordingly when
sending the response to the client. (In Zope 3, all charset
negotation between the client and the server takes place in the
publisher.)
* Added ``IHTTPCharset`` adapter for ``IHTTPRequest`` so that
application can find out the preferred character set of the HTTP
client (Zope 2 applications needs to take care of their own charset
header). The adapter is used for the automatically-generated forms
when determining encodings for unicode field content.
* Modified edit.pt to make sure editforms have only one body tag.
* Fixed the ``INameChooser`` adapter for ObjectManagers (e.g. Zope 2
folders) and added unit tests.
* Fixed small bug in BrowserDefault which caused an error if the class is
defaultViewable but the object's interfaces have no defaultView.
Five 1.0 (2005-04-27)
=====================
Features
--------
...
...
lib/python/Products/Five/CREDITS.txt
View file @
1534f218
...
...
@@ -27,6 +27,8 @@ Five contributors
- Dieter Maurer (dieter@handshake.de)
- Yvo Schubbe (y.2005-@wcm-solutions.de)
Thank you
---------
...
...
lib/python/Products/Five/README.txt
View file @
1534f218
...
...
@@ -43,7 +43,7 @@ For more information, see ``doc/features.txt``.
How to install Five
-------------------
Five should already be installed in Zope 2.8
.
See ``INSTALL.txt``
.
How to use Five
---------------
...
...
lib/python/Products/Five/ReuseUtils.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Utils to be reused
$Id: ReuseUtils.py 12912 2005-05-31 09:58:59Z philikon $
"""
from
new
import
function
def
rebindFunction
(
f
,
rebindDir
=
None
,
**
rebinds
):
...
...
lib/python/Products/Five/TrustedExpression.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,7 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Trusted expression
$Id: TrustedExpression.py 12912 2005-05-31 09:58:59Z philikon $
"""
from
sys
import
modules
from
Products.PageTemplates.PythonExpr
import
PythonExpr
...
...
lib/python/Products/Five/__init__.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,7 +13,7 @@
##############################################################################
"""Initialize the Five product
$Id: __init__.py 1
0829 2005-04-18 19:18:27
Z philikon $
$Id: __init__.py 1
2915 2005-05-31 10:23:19
Z philikon $
"""
import
Acquisition
from
Globals
import
INSTANCE_HOME
...
...
lib/python/Products/Five/adding.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -65,7 +66,11 @@ class BasicAdding(Implicit, BrowserView):
name
=
chooser
.
chooseName
(
self
.
contentName
or
''
,
content
)
elif
name
==
''
:
name
=
chooser
.
chooseName
(
''
,
content
)
chooser
.
checkName
(
name
,
container
)
else
:
# Invoke the name chooser even when we have a
# name. It'll do useful things with it like converting
# the incoming unicode to an ASCII string.
name
=
chooser
.
chooseName
(
name
,
container
)
content
.
id
=
name
container
.
_setObject
(
name
,
content
)
...
...
@@ -210,14 +215,27 @@ class ObjectManagerNameChooser:
self
.
context
=
context
def
checkName
(
self
,
name
,
object
):
# ObjectManager can only deal with ASCII names. Specially
# ObjectManager._checkId can only deal with strings.
try
:
name
=
name
.
encode
(
'ascii'
)
except
UnicodeDecodeError
:
raise
UserError
,
"Id must contain only ASCII characters."
try
:
self
.
context
.
_checkId
(
name
,
allow_dup
=
False
)
except
BadRequest
:
raise
UserError
,
"Id is in use or invalid"
except
BadRequest
,
e
:
msg
=
' '
.
join
(
e
.
args
)
or
"Id is in use or invalid"
raise
UserError
,
msg
def
chooseName
(
self
,
name
,
object
):
if
not
name
:
name
=
object
.
__class__
.
__name__
else
:
try
:
name
=
name
.
encode
(
'ascii'
)
except
UnicodeDecodeError
:
raise
UserError
,
"Id must contain only ASCII characters."
dot
=
name
.
rfind
(
'.'
)
if
dot
>=
0
:
...
...
@@ -227,18 +245,17 @@ class ObjectManagerNameChooser:
suffix
=
''
n
=
name
+
suffix
i
=
1
i
=
0
while
True
:
i
+=
1
try
:
container
.
_getOb
(
n
)
self
.
context
.
_getOb
(
n
)
except
AttributeError
:
pass
else
:
break
i
+=
1
n
=
name
+
'-'
+
str
(
i
)
+
suffix
# Make sure tha name is valid. We may have started with something bad.
# Make sure the name is valid. We may have started with
# something bad.
self
.
checkName
(
n
,
object
)
return
n
lib/python/Products/Five/bridge.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,9 +13,8 @@
##############################################################################
""" Z2 -> Z3 bridge utilities.
$Id$
$Id
: bridge.py 12915 2005-05-31 10:23:19Z philikon
$
"""
from
Interface._InterfaceClass
import
Interface
as
Z2_InterfaceClass
from
Interface
import
Interface
as
Z2_Interface
from
Interface
import
Attribute
as
Z2_Attribute
...
...
lib/python/Products/Five/browser.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,9 +13,8 @@
##############################################################################
"""Provide basic browser functionality
$Id: browser.py 1
0829 2005-04-18 19:18:27
Z philikon $
$Id: browser.py 1
2915 2005-05-31 10:23:19
Z philikon $
"""
# python
import
sys
from
datetime
import
datetime
...
...
@@ -32,6 +32,9 @@ from interfaces import ITraversable
from
zope.interface
import
implements
from
zope.component
import
getViewProviding
from
zope.app.traversing.browser.interfaces
import
IAbsoluteURL
from
zope.publisher.browser
import
isCGI_NAME
from
zope.i18n.interfaces
import
IUserPreferredCharsets
from
zope.app.location.interfaces
import
ILocation
from
zope.app.location
import
LocationProxy
from
zope.app.form.utility
import
setUpEditWidgets
,
applyWidgetsChanges
...
...
@@ -128,6 +131,7 @@ class EditView(BrowserView):
errors
=
()
update_status
=
None
label
=
''
charsets
=
None
# Fall-back field names computes from schema
fieldNames
=
property
(
lambda
self
:
getFieldNamesInOrder
(
self
.
schema
))
...
...
@@ -136,6 +140,8 @@ class EditView(BrowserView):
def
__init__
(
self
,
context
,
request
):
BrowserView
.
__init__
(
self
,
context
,
request
)
self
.
_processInputs
()
self
.
_setPageEncoding
()
self
.
_setUpWidgets
()
def
_setUpWidgets
(
self
):
...
...
@@ -148,6 +154,36 @@ class EditView(BrowserView):
setUpEditWidgets
(
self
,
self
.
schema
,
source
=
self
.
adapted
,
names
=
self
.
fieldNames
)
# taken from zope.publisher.browser.BrowserRequest
def
_decode
(
self
,
text
):
"""Try to decode the text using one of the available charsets."""
if
self
.
charsets
is
None
:
envadapter
=
IUserPreferredCharsets
(
self
.
request
)
self
.
charsets
=
envadapter
.
getPreferredCharsets
()
or
[
'utf-8'
]
for
charset
in
self
.
charsets
:
try
:
text
=
unicode
(
text
,
charset
)
break
except
UnicodeError
:
pass
return
text
def
_processInputs
(
self
):
request
=
self
.
request
for
name
,
value
in
request
.
form
.
items
():
if
(
not
(
isCGI_NAME
(
name
)
or
name
.
startswith
(
'HTTP_'
))
and
isinstance
(
value
,
str
)):
request
.
form
[
name
]
=
self
.
_decode
(
value
)
def
_setPageEncoding
(
self
):
"""Set the encoding of the form page via the Content-Type header.
ZPublisher uses the value of this header to determine how to
encode unicode data for the browser."""
envadapter
=
IUserPreferredCharsets
(
self
.
request
)
charsets
=
envadapter
.
getPreferredCharsets
()
or
[
'utf-8'
]
self
.
request
.
RESPONSE
.
setHeader
(
'Content-Type'
,
'text/html; charset=%s'
%
charsets
[
0
])
def
setPrefix
(
self
,
prefix
):
for
widget
in
self
.
widgets
():
widget
.
setPrefix
(
prefix
)
...
...
@@ -183,7 +219,7 @@ class EditView(BrowserView):
except
WidgetsError
,
errors
:
self
.
errors
=
errors
status
=
"An error occured."
transaction
.
get
().
abort
()
transaction
.
abort
()
else
:
setUpEditWidgets
(
self
,
self
.
schema
,
source
=
self
.
adapted
,
ignoreStickyValues
=
True
,
...
...
lib/python/Products/Five/browserconfigure.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -15,7 +16,7 @@
Directives to emulate the 'http://namespaces.zope.org/browser'
namespace in ZCML known from zope.app.
$Id: browserconfigure.py 1
1479 2005-04-26 13:47:37Z dreamcatcher
$
$Id: browserconfigure.py 1
2915 2005-05-31 10:23:19Z philikon
$
"""
import
os
...
...
lib/python/Products/Five/configure.zcml
View file @
1534f218
...
...
@@ -7,6 +7,7 @@
<include file="interfaces.zcml" />
<include file="permissions.zcml" />
<include file="browser.zcml" />
<include file="i18n.zcml" />
<include package="zope.app.traversing" />
<include package="zope.app.form.browser" />
...
...
lib/python/Products/Five/doc/main.txt
View file @
1534f218
...
...
@@ -32,8 +32,12 @@ system for us all.
Download
--------
2005-04-27 -- We have released Five 1.0! This is also the version that
will be included in Zope 2.8. Download it here:
2005-05-31 -- We have released Five 1.0.1! This is also the version
that will be included in Zope 2.8. Download it here:
http://codespeak.net/z3/five/release/Five-1.0.1.tgz
2005-04-27 -- We have released Five 1.0! Download it here:
http://codespeak.net/z3/five/release/Five-1.0.tgz
...
...
lib/python/Products/Five/edit.pt
View file @
1534f218
<tal:tag
condition=
"view/update"
/>
<html
metal:use-macro=
"context/@@standard_macros/page"
>
<body
metal:fill-slot=
"body"
>
<body>
<div
metal:fill-slot=
"body"
>
<div
metal:define-macro=
"body"
>
...
...
@@ -31,11 +32,11 @@
<div
class=
"label"
>
Extra top
</div>
<div
class=
"field"
><input
type=
"text"
style=
"width:100%"
/></div>
</div>
<div
metal:use-macro=
"context/@@widget_macros/widget_rows"
/>
<div
class=
"separator"
></div>
<div
class=
"row"
metal:define-slot=
"extra_bottom"
tal:replace=
"nothing"
>
<div
class=
"label"
>
Extra bottom
</div>
...
...
@@ -46,9 +47,9 @@
<div
class=
"row"
>
<div
class=
"controls"
>
<input
type=
"submit"
value=
"Refresh"
<input
type=
"submit"
value=
"Refresh"
i18n:attributes=
"value refresh-button"
/>
<input
type=
"submit"
name=
"UPDATE_SUBMIT"
value=
"Change"
<input
type=
"submit"
name=
"UPDATE_SUBMIT"
value=
"Change"
i18n:attributes=
"value submit-button"
/>
</div>
</div>
...
...
@@ -59,6 +60,8 @@
</form>
</div>
</div>
</body>
...
...
lib/python/Products/Five/eventconfigure.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -14,9 +15,8 @@
Use 'structured monkey patching' to enable zope.app.container event sending for
Zope 2 objects.
$Id: eventconfigure.py 1
0337 2005-04-05 16:01:21
Z philikon $
$Id: eventconfigure.py 1
2915 2005-05-31 10:23:19
Z philikon $
"""
from
Products.Five.fiveconfigure
import
isFiveMethod
from
zope.event
import
notify
from
zope.interface
import
implements
...
...
lib/python/Products/Five/fiveconfigure.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -14,7 +15,7 @@
These directives are specific to Five and have no equivalents in Zope 3.
$Id: fiveconfigure.py
8255 2005-01-13 14:05:46Z regebro
$
$Id: fiveconfigure.py
12915 2005-05-31 10:23:19Z philikon
$
"""
import
os
...
...
lib/python/Products/Five/fivedirectives.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,7 +13,7 @@
##############################################################################
"""Five ZCML directive schemas
$Id: fivedirectives.py
8255 2005-01-13 14:05:46Z regebro
$
$Id: fivedirectives.py
12915 2005-05-31 10:23:19Z philikon
$
"""
from
zope.interface
import
Interface
from
zope.app.publisher.browser.metadirectives
import
IBasicResourceInformation
...
...
lib/python/Products/Five/i18n.zcml
0 → 100644
View file @
1534f218
<configure xmlns="http://namespaces.zope.org/zope">
<adapter
factory="zope.publisher.http.HTTPCharsets"
for="zope.publisher.interfaces.http.IHTTPRequest"
provides="zope.i18n.interfaces.IUserPreferredCharsets"
/>
</configure>
lib/python/Products/Five/interfaces.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2000-2003 Zope Corporation and Contributors.
# Copyright (c) 2004 Five Contributors.
# All Rights Reserved.
# Copyright (c) 2000-2005 Zope Corporation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -14,7 +12,7 @@
##############################################################################
"""Five interfaces
$Id: interfaces.py 12
029 2005-05-06 17:04:32Z yuppie
$
$Id: interfaces.py 12
915 2005-05-31 10:23:19Z philikon
$
"""
from
zope.interface
import
Interface
,
Attribute
from
zope.interface.interfaces
import
IInterface
...
...
lib/python/Products/Five/metaclass.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
lib/python/Products/Five/metaconfigure.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,7 +13,7 @@
##############################################################################
"""Generic Components ZCML Handlers
$Id: metaconfigure.py
5287 2004-06-25 11:42:27
Z philikon $
$Id: metaconfigure.py
12915 2005-05-31 10:23:19
Z philikon $
"""
from
types
import
ModuleType
...
...
lib/python/Products/Five/pagetemplatefile.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,8 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
'''A 'PageTemplateFile' without security restrictions.'''
"""A 'PageTemplateFile' without security restrictions.
$Id: pagetemplatefile.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
os
,
sys
# Zope 2
...
...
lib/python/Products/Five/resource.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -14,7 +15,6 @@
$Id: browser.py 5259 2004-06-23 15:59:52Z philikon $
"""
import
os
import
urllib
...
...
lib/python/Products/Five/security.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,7 +13,7 @@
##############################################################################
"""Five security handling
$Id: security.py
8281 2005-01-14 18:20:18Z regebro
$
$Id: security.py
12915 2005-05-31 10:23:19Z philikon
$
"""
from
zope.interface
import
implements
from
zope.component
import
queryUtility
,
getUtility
...
...
lib/python/Products/Five/sizeconfigure.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -13,7 +14,7 @@
"""Use structured monkey-patching to enable ``ISized`` adapters for
Zope 2 objects.
$Id: sizeconfigure.py 1
0365 2005-04-06 13:24:16
Z philikon $
$Id: sizeconfigure.py 1
2915 2005-05-31 10:23:19
Z philikon $
"""
from
zope.app.size.interfaces
import
ISized
from
Products.Five.fiveconfigure
import
isFiveMethod
...
...
lib/python/Products/Five/skin.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,7 +13,7 @@
##############################################################################
"""Mimick the Zope 3 skinning system in Five.
$Id: skin.py 1
0830 2005-04-18 19:22:4
9Z philikon $
$Id: skin.py 1
2915 2005-05-31 10:23:1
9Z philikon $
"""
from
zope.interface.common.mapping
import
IItemMapping
from
zope.interface
import
implements
...
...
lib/python/Products/Five/tests/__init__.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
# import this
lib/python/Products/Five/tests/adding.txt
0 → 100644
View file @
1534f218
============
Adding tests
============
ObjectManagerNameChooser
------------------------
First we need to import and setup some prerequisites:
>>> from zope.app.container.interfaces import INameChooser
>>> from Products.Five.tests.products.FiveTest.helpers import \
... manage_addFiveTraversableFolder
>>> manage_addFiveTraversableFolder(self.folder, 'testoid', 'Testoid')
>>> chooser = INameChooser(self.folder)
Now we can start. ``INameChooser`` defines a ``checkName()`` method
that checks whether a given name is valid in the container or not.
Under the hood, ``ObjectManagerNameChooser`` calls ``_checkId()`` of
the object manager. Valid names/ids are those that aren't in use yet
and don't contain invalid characters.
>>> chooser.checkName('abc', object())
>>> chooser.checkName('testoid', object())
Traceback (most recent call last):
...
UserError: The id "testoid" is invalid - it is already in use.
>>> chooser.checkName('slash/slash', object())
Traceback (most recent call last):
...
UserError: The id "slash/slash" contains characters illegal in URLs.
``INameChooser`` also promises us a ``chooseName()`` method that
chooses a name for us in case we don't have one or that chooses a
different name in case the one we chose was invalid.
>>> chooser.chooseName('', self.folder.testoid)
'FiveTraversableFolder'
>>> chooser.chooseName('abc', self.folder.testoid)
'abc'
>>> chooser.chooseName('testoid', self.folder.testoid)
'testoid-1'
Of course, if we start out with something bad, it isn't going to
become good automagically:
>>> chooser.chooseName('slash/slash', object())
Traceback (most recent call last):
...
UserError: The id "slash/slash" contains characters illegal in URLs.
lib/python/Products/Five/tests/dummy.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Dummy objects and views for the security tests
$Id: dummy.py 12915 2005-05-31 10:23:19Z philikon $
"""
from
zope.interface
import
Interface
,
implements
from
Products.Five
import
BrowserView
...
...
lib/python/Products/Five/tests/fivetest.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,7 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Five test fixtures.
$Id: fivetest.py 12915 2005-05-31 10:23:19Z philikon $
"""
# ZopeTestCase was not designed to run tests as part of the
# Zope test suite proper. In particular, it intercepts product
# installation. We have to work around this for the Five tests
...
...
lib/python/Products/Five/tests/forms.txt
0 → 100644
View file @
1534f218
This diff is collapsed.
Click to expand it.
lib/python/Products/Five/tests/products/FiveTest/__init__.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
#import simplecontent
#import fancycontent
...
...
lib/python/Products/Five/tests/products/FiveTest/browser.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Browser views for tests.
$Id: browser.py 12915 2005-05-31 10:23:19Z philikon $
"""
from
Products.Five
import
BrowserView
from
Products.Five
import
StandardMacros
as
BaseMacros
from
simplecontent
import
FieldSimpleContent
...
...
lib/python/Products/Five/tests/products/FiveTest/classes.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,7 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Adapter test classes.
$Id: classes.py 12915 2005-05-31 10:23:19Z philikon $
"""
from
zope.interface
import
implements
from
interfaces
import
IAdaptable
,
IAdapted
,
IOrigin
,
IDestination
...
...
lib/python/Products/Five/tests/products/FiveTest/configure.zcml
View file @
1534f218
...
...
@@ -355,7 +355,7 @@
<browser:addform
schema=".interfaces.IFieldSimpleContent"
content_factory=".simplecontent.FieldSimpleContent"
name="add
simple
content.html"
name="add
field
content.html"
permission="zope2.Public"
/>
...
...
lib/python/Products/Five/tests/products/FiveTest/fancycontent.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Fancy content
$Id: fancycontent.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
Acquisition
from
AccessControl
import
ClassSecurityInfo
from
OFS.SimpleItem
import
SimpleItem
...
...
lib/python/Products/Five/tests/products/FiveTest/helpers.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,7 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test helpers
$Id: helpers.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
urllib
def
add_and_edit
(
self
,
id
,
REQUEST
):
...
...
lib/python/Products/Five/tests/products/FiveTest/interfaces.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,8 +11,12 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test product interfaces
$Id: interfaces.py 12915 2005-05-31 10:23:19Z philikon $
"""
from
zope.interface
import
Interface
from
zope.schema
import
Text
,
TextLine
,
Object
from
zope.schema
import
Text
,
TextLine
,
Object
,
Int
,
List
class
IAdaptable
(
Interface
):
"""This is a Zope 3 interface.
...
...
@@ -50,19 +55,34 @@ class IFancyContent(Interface):
pass
class
IFieldSimpleContent
(
ISimpleContent
):
title
=
TextLine
(
title
=
u"Title"
,
description
=
u"A short description of the event."
,
default
=
u""
,
required
=
True
)
required
=
True
)
description
=
Text
(
title
=
u"Description"
,
description
=
u"A long description of the event."
,
default
=
u""
,
required
=
False
)
required
=
False
)
somenumber
=
Int
(
title
=
u"Some number"
,
default
=
0
,
required
=
False
)
somelist
=
List
(
title
=
u"Some List"
,
value_type
=
TextLine
(
title
=
u"Some item"
),
default
=
[],
required
=
False
)
class
IComplexSchemaContent
(
Interface
):
fishtype
=
TextLine
(
...
...
@@ -76,4 +96,3 @@ class IComplexSchemaContent(Interface):
schema
=
IFieldSimpleContent
,
description
=
u"The fishy object"
,
required
=
True
)
lib/python/Products/Five/tests/products/FiveTest/metaconfigure.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -14,7 +15,6 @@
$Id: metaconfigure.py 5287 2004-06-25 11:42:27Z philikon $
"""
from
zope.interface
import
Interface
from
zope.configuration.fields
import
GlobalObject
from
zope.schema
import
TextLine
...
...
lib/python/Products/Five/tests/products/FiveTest/schemacontent.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Schema content implementation
$Id: schemacontent.py 12915 2005-05-31 10:23:19Z philikon $
"""
from
OFS.SimpleItem
import
SimpleItem
from
Globals
import
InitializeClass
...
...
lib/python/Products/Five/tests/products/FiveTest/simplecontent.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,7 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Simple content implementationm
$Id: simplecontent.py 12915 2005-05-31 10:23:19Z philikon $
"""
from
OFS.SimpleItem
import
SimpleItem
from
Globals
import
InitializeClass
from
AccessControl
import
ClassSecurityInfo
...
...
lib/python/Products/Five/tests/products/FiveTest/size.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Size adapters
$Id: size.py 12915 2005-05-31 10:23:19Z philikon $
"""
from
zope.interface
import
implements
from
zope.app.size.interfaces
import
ISized
...
...
lib/python/Products/Five/tests/products/FiveTest/subscriber.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,7 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Event test fixtures
$Id: subscriber.py 12915 2005-05-31 10:23:19Z philikon $
"""
class
EventCatcher
:
def
__init__
(
self
):
self
.
_events
=
[]
...
...
lib/python/Products/Five/tests/runalltests.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
# Runs all tests in the current directory
#
# Execute like:
...
...
lib/python/Products/Five/tests/test_adding.py
0 → 100644
View file @
1534f218
##############################################################################
#
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test adding views
$Id: test_adding.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
import
Products.Five.tests.fivetest
# starts Zope, loads Five, etc.
def
test_suite
():
from
Testing.ZopeTestCase
import
ZopeDocFileSuite
return
ZopeDocFileSuite
(
'adding.txt'
,
package
=
"Products.Five.tests"
)
if
__name__
==
'__main__'
:
framework
()
lib/python/Products/Five/tests/test_bridge.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
lib/python/Products/Five/tests/test_editform.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,81 +11,57 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test forms
$Id$
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
from
Products.Five.tests.fivetest
import
*
from
AccessControl
import
Unauthorized
from
zope.app.form.browser.submit
import
Update
from
Products.Five.tests.products.FiveTest.simplecontent
import
manage_addFieldSimpleContent
from
Products.Five.tests.products.FiveTest.helpers
import
manage_addFiveTraversableFolder
from
Products.Five.tests.products.FiveTest.schemacontent
import
manage_addComplexSchemaContent
import
Products.Five.tests.fivetest
# starts Zope, loads Five, etc.
import
unittest
from
Testing.ZopeTestCase
import
ZopeDocTestSuite
from
Testing.ZopeTestCase
import
FunctionalDocFileSuite
class
EditFormTest
(
Functional
,
FiveTestCase
):
def
test_get_widgets_for_schema_fields
():
"""
>>> from zope.schema import Choice, TextLine
>>> salutation = Choice(title=u'Salutation',
... values=("Mr.", "Mrs.", "Captain", "Don"))
>>> contactname = TextLine(title=u'Name')
>>> from Products.Five.traversable import FakeRequest
>>> request = FakeRequest()
>>> salutation = salutation.bind(request)
>>> contactname = contactname.bind(request)
def
afterSetUp
(
self
):
manage_addFieldSimpleContent
(
self
.
folder
,
'edittest'
,
'Test'
)
uf
=
self
.
folder
.
acl_users
uf
.
_doAddUser
(
'viewer'
,
'secret'
,
[],
[])
uf
.
_doAddUser
(
'manager'
,
'r00t'
,
[
'Manager'
],
[])
>>> from zope.app import zapi
>>> from zope.app.form.interfaces import IInputWidget
>>> from zope.app.form.browser.textwidgets import TextWidget
>>> from zope.app.form.browser.itemswidgets import DropdownWidget
def
test_editform
(
self
):
response
=
self
.
publish
(
'/test_folder_1_/edittest/edit.html'
,
basic
=
'manager:r00t'
)
# we're using a GET request to post variables, but seems to be
# the easiest..
response
=
self
.
publish
(
'/test_folder_1_/edittest/edit.html?%s=1&field.title=FooTitle&field.description=FooDescription'
%
Update
,
basic
=
'manager:r00t'
)
self
.
assertEquals
(
'FooTitle'
,
self
.
folder
.
edittest
.
title
)
self
.
assertEquals
(
'FooDescription'
,
self
.
folder
.
edittest
.
description
)
>>> view1 = zapi.getViewProviding(contactname, IInputWidget, request)
>>> view1.__class__ == TextWidget
True
def
test_editform_invalid
(
self
):
# missing title, which is required
self
.
folder
.
edittest
.
description
=
''
>>> view2 = zapi.getViewProviding(salutation, IInputWidget, request)
>>> view2.__class__ == DropdownWidget
True
"""
response
=
self
.
publish
(
'/test_folder_1_/edittest/edit.html?%s=1&field.title=&field.description=BarDescription'
%
Update
,
basic
=
'manager:r00t'
)
# we expect that we get a 200 Ok
self
.
assertEqual
(
200
,
response
.
getStatus
())
self
.
assertEquals
(
'Test'
,
self
.
folder
.
edittest
.
title
)
self
.
assertEquals
(
''
,
self
.
folder
.
edittest
.
description
)
def
test_addform
(
self
):
manage_addFiveTraversableFolder
(
self
.
folder
,
'ftf'
)
self
.
folder
=
self
.
folder
.
ftf
response
=
self
.
publish
(
'/test_folder_1_/ftf/+/addsimplecontent.html'
,
basic
=
'manager:r00t'
)
self
.
assertEquals
(
200
,
response
.
getStatus
())
# we're using a GET request to post variables, but seems to be
# the easiest..
response
=
self
.
publish
(
'/test_folder_1_/ftf/+/addsimplecontent.html?%s=1&add_input_name=alpha&field.title=FooTitle&field.description=FooDescription'
%
Update
,
basic
=
'manager:r00t'
)
# we expect to get a 302 (redirect)
self
.
assertEquals
(
302
,
response
.
getStatus
())
# we expect the object to be there with the right id
self
.
assertEquals
(
'alpha'
,
self
.
folder
.
alpha
.
id
)
self
.
assertEquals
(
'FooTitle'
,
self
.
folder
.
alpha
.
title
)
self
.
assertEquals
(
'FooDescription'
,
self
.
folder
.
alpha
.
description
)
def
test_objectWidget
(
self
):
manage_addComplexSchemaContent
(
self
.
folder
,
'csc'
)
response
=
self
.
publish
(
'/test_folder_1_/csc/edit.html'
,
basic
=
'manager:r00t'
)
self
.
assertEquals
(
200
,
response
.
getStatus
())
def
setUpForms
(
self
):
uf
=
self
.
folder
.
acl_users
uf
.
_doAddUser
(
'viewer'
,
'secret'
,
[],
[])
uf
.
_doAddUser
(
'manager'
,
'r00t'
,
[
'Manager'
],
[])
def
test_suite
():
from
unittest
import
TestSuite
,
makeSuite
suite
=
TestSuite
()
suite
.
addTest
(
makeSuite
(
EditFormTest
))
return
suite
return
unittest
.
TestSuite
((
ZopeDocTestSuite
(),
FunctionalDocFileSuite
(
'forms.txt'
,
package
=
"Products.Five.tests"
,
setUp
=
setUpForms
),
))
if
__name__
==
'__main__'
:
framework
()
lib/python/Products/Five/tests/test_event.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,8 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
# t
est events triggered by Five
"""T
est events triggered by Five
$Id: test_event.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
...
...
@@ -61,7 +64,7 @@ class EventTest(FiveTestCase):
manage_addSimpleContent
(
self
.
folder
,
'foo'
,
'Foo'
)
# somehow we need to at least commit a subtransaction to make
# renaming succeed
transaction
.
get
().
commit
(
1
)
transaction
.
commit
(
1
)
self
.
folder
.
manage_renameObject
(
'foo'
,
'bar'
)
bar
=
self
.
folder
.
bar
events
=
objectEventCatcher
.
getEvents
()
...
...
@@ -95,7 +98,7 @@ class EventTest(FiveTestCase):
manage_addSimpleContent
(
folder1
,
'foo'
,
'Foo'
)
foo
=
folder1
.
foo
# need to trigger subtransaction before copy/paste can work
transaction
.
get
().
commit
(
1
)
transaction
.
commit
(
1
)
cb
=
folder1
.
manage_cutObjects
([
'foo'
])
folder2
.
manage_pasteObjects
(
cb
)
newfoo
=
folder2
.
foo
...
...
@@ -125,7 +128,7 @@ class EventTest(FiveTestCase):
manage_addNoVerifyPasteFolder
(
self
.
folder
,
'folder1'
)
folder1
=
self
.
folder
.
folder1
# need to trigger subtransaction before copy/paste can work
transaction
.
get
().
commit
(
1
)
transaction
.
commit
(
1
)
cb
=
self
.
folder
.
manage_copyObjects
([
'foo'
])
folder1
.
manage_pasteObjects
(
cb
)
foo_copy
=
folder1
.
foo
...
...
lib/python/Products/Five/tests/test_five.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Five tests.
$Id: test_five.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
...
...
lib/python/Products/Five/tests/test_security.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test security induced by ZCML
$Id: test_security.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
...
...
lib/python/Products/Five/tests/test_security2.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test security from restricted Python interpreter
$Id: test_security2.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
...
...
@@ -214,7 +219,7 @@ class PublishTest(Functional, FiveTestCase):
manage_addFiveTraversableFolder
(
self
.
folder
,
'ftf'
)
# Unprotected as anonymous
response
=
self
.
publish
(
'/test_folder_1_/ftf/+/add
simple
content.html'
)
response
=
self
.
publish
(
'/test_folder_1_/ftf/+/add
field
content.html'
)
self
.
assertEqual
(
response
.
getStatus
(),
200
)
# Protected as manager
...
...
lib/python/Products/Five/tests/test_viewable.py
0 → 100644
View file @
1534f218
##############################################################################
#
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Unit tests for the viewable module.
$Id: test_viewable.py 12948 2005-05-31 20:24:58Z philikon $
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
import
Products.Five.tests.fivetest
# starts Zope, loads Five, etc.
def
test_defaultView
():
"""
Take a class Foo and an interface I1::
>>> class Foo:
... pass
>>> from zope.interface import Interface
>>> class I1(Interface):
... pass
Set up a default view for I1::
>>> from zope.app import zapi
>>> pres = zapi.getGlobalService('Presentation')
>>> from zope.publisher.interfaces.browser import IBrowserRequest
>>> pres.setDefaultViewName(I1, IBrowserRequest, 'foo.html')
and a BrowserDefault for an instance of Foo::
>>> foo = Foo()
>>> from Products.Five.viewable import BrowserDefault
>>> bd = BrowserDefault(foo)
You'll see that no default view is returned::
>>> request = self.app.REQUEST
>>> obj, path = bd.defaultView(request)
>>> obj is foo
True
>>> path is None
True
unless you mark the object with I1::
>>> from zope.interface import directlyProvides
>>> directlyProvides(foo, I1)
>>> obj, path = bd.defaultView(request)
>>> obj is foo
True
>>> path
['foo.html']
"""
def
test_suite
():
from
Testing.ZopeTestCase
import
ZopeDocTestSuite
return
ZopeDocTestSuite
()
if
__name__
==
'__main__'
:
framework
()
lib/python/Products/Five/tests/zopeconf.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,11 +11,13 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Load zope.conf for tests.
$Id: zopeconf.py 12915 2005-05-31 10:23:19Z philikon $
"""
import
os
from
os.path
import
join
,
abspath
,
dirname
,
split
,
exists
def
process
():
"""Read in zope.conf configuration file.
...
...
@@ -35,5 +38,5 @@ def process():
_config
=
join
(
_prefix
,
'etc'
,
'zope.conf'
)
if
exists
(
_config
):
from
Zope
2
import
configure
from
Zope
import
configure
configure
(
_config
)
lib/python/Products/Five/traversable.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,7 +13,7 @@
##############################################################################
"""Machinery for making things traversable through adaptation
$Id: traversable.py
9786 2005-03-15 12:53:39Z efge
$
$Id: traversable.py
12915 2005-05-31 10:23:19Z philikon
$
"""
from
zExceptions
import
NotFound
from
zope.exceptions
import
NotFoundError
...
...
lib/python/Products/Five/version.txt
View file @
1534f218
Five 1.0
-z28
Five 1.0
.1
lib/python/Products/Five/viewable.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,9 +13,8 @@
##############################################################################
"""Machinery for making things viewable
$Id:
traversable.py 5763 2004-07-28 20:15:11Z dreamcatcher
$
$Id:
viewable.py 12915 2005-05-31 10:23:19Z philikon
$
"""
import
inspect
from
zExceptions
import
NotFound
from
zope.exceptions
import
NotFoundError
...
...
@@ -104,9 +104,8 @@ class BrowserDefault(object):
def
defaultView
(
self
,
request
):
context
=
self
.
context
name
=
None
try
:
name
=
getDefaultViewName
(
context
,
request
)
return
context
,
[
name
,]
except
ComponentLookupError
:
pass
return
context
,
[
name
,]
return
context
,
None
lib/python/Products/Five/zcml.py
View file @
1534f218
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -12,7 +13,7 @@
##############################################################################
"""ZCML machinery
$Id: zcml.py 1
0534 2005-04-11 15:06:02Z dreamcatcher
$
$Id: zcml.py 1
2915 2005-05-31 10:23:19Z philikon
$
"""
import
os
from
zope.configuration
import
xmlconfig
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment