Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope-container
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
Boxiang Sun
zope-container
Commits
00f6a5c3
Commit
00f6a5c3
authored
Jan 28, 2009
by
Wolfgang Schnerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove browser subpackage
parent
f1f6cc98
Changes
21
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
0 additions
and
3054 deletions
+0
-3054
src/zope/container/browser/__init__.py
src/zope/container/browser/__init__.py
+0
-2
src/zope/container/browser/add.pt
src/zope/container/browser/add.pt
+0
-58
src/zope/container/browser/adding.py
src/zope/container/browser/adding.py
+0
-211
src/zope/container/browser/commontasks.pt
src/zope/container/browser/commontasks.pt
+0
-41
src/zope/container/browser/configure.zcml
src/zope/container/browser/configure.zcml
+0
-20
src/zope/container/browser/contents.pt
src/zope/container/browser/contents.pt
+0
-193
src/zope/container/browser/contents.py
src/zope/container/browser/contents.py
+0
-464
src/zope/container/browser/find.pt
src/zope/container/browser/find.pt
+0
-22
src/zope/container/browser/find.py
src/zope/container/browser/find.py
+0
-42
src/zope/container/browser/index.pt
src/zope/container/browser/index.pt
+0
-66
src/zope/container/browser/meta.zcml
src/zope/container/browser/meta.zcml
+0
-16
src/zope/container/browser/metaconfigure.py
src/zope/container/browser/metaconfigure.py
+0
-88
src/zope/container/browser/tests/__init__.py
src/zope/container/browser/tests/__init__.py
+0
-2
src/zope/container/browser/tests/configure.zcml
src/zope/container/browser/tests/configure.zcml
+0
-16
src/zope/container/browser/tests/index.txt
src/zope/container/browser/tests/index.txt
+0
-18
src/zope/container/browser/tests/test_adding.py
src/zope/container/browser/tests/test_adding.py
+0
-586
src/zope/container/browser/tests/test_contents.py
src/zope/container/browser/tests/test_contents.py
+0
-380
src/zope/container/browser/tests/test_contents_functional.py
src/zope/container/browser/tests/test_contents_functional.py
+0
-375
src/zope/container/browser/tests/test_directive.py
src/zope/container/browser/tests/test_directive.py
+0
-294
src/zope/container/ftesting.zcml
src/zope/container/ftesting.zcml
+0
-57
src/zope/container/tests/test_view_permissions.py
src/zope/container/tests/test_view_permissions.py
+0
-103
No files found.
src/zope/container/browser/__init__.py
deleted
100644 → 0
View file @
f1f6cc98
#
# This file is necessary to make this directory a package.
src/zope/container/browser/add.pt
deleted
100644 → 0
View file @
f1f6cc98
<html
metal:use-macro=
"context/@@standard_macros/addingdialog"
i18n:domain=
"zope"
>
<body>
<div
metal:fill-slot=
"body"
>
<form
method=
"post"
action=
"action.html"
>
<table
class=
"TypeListing"
cellpadding=
"3"
>
<tal:block
define=
"title view/title | nothing"
>
<caption
tal:condition=
"title"
tal:content=
"title"
i18n:translate=
""
>
Inserted title
</caption>
<caption
tal:condition=
"not:title"
i18n:translate=
""
>
Add Content
</caption>
</tal:block>
<tbody
tal:define=
"infos view/addingInfo"
>
<tr
tal:repeat=
"info infos"
>
<td
class=
"Selector"
>
<input
type=
"radio"
name=
"type_name"
tal:attributes=
"value info/action;
id info/action;
checked python:len(infos)==1"
/>
</td>
<td
class=
"TypeName"
>
<label
style=
"font-weight: bold;"
tal:attributes=
"for info/action"
>
<span
tal:replace=
"info/title"
i18n:translate=
""
>
Folder
</span>
</label>
<div
class=
"TypeDescription"
tal:content=
"info/description"
i18n:translate=
""
>
Folders are generic containers for content, including other
folders.
</div>
</td>
</tr>
<tr>
<td><br
/></td>
<td><input
type=
"text"
name=
"id"
tal:condition=
"view/nameAllowed"
tal:attributes=
"value request/id | nothing"
/>
<input
type=
"submit"
name=
"add"
value=
" Add "
i18n:attributes=
"value add-button"
/>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</body>
</html>
src/zope/container/browser/adding.py
deleted
100644 → 0
View file @
f1f6cc98
##############################################################################
#
# 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.
# 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.
#
##############################################################################
"""Adding View
The Adding View is used to add new objects to a container. It is sort of a
factory screen.
$Id$
"""
__docformat__
=
'restructuredtext'
from
zope.app.container.constraints
import
checkFactory
from
zope.app.container.constraints
import
checkObject
from
zope.app.container.i18n
import
ZopeMessageFactory
as
_
from
zope.app.container.interfaces
import
IAdding
from
zope.app.container.interfaces
import
IContainerNamesContainer
from
zope.app.container.interfaces
import
INameChooser
from
zope.app.pagetemplate.viewpagetemplatefile
import
ViewPageTemplateFile
from
zope.app.publisher.browser.menu
import
getMenu
from
zope.component
import
getMultiAdapter
from
zope.component
import
getUtility
from
zope.component
import
queryAdapter
from
zope.component
import
queryMultiAdapter
from
zope.component
import
queryUtility
from
zope.component.interfaces
import
IFactory
from
zope.event
import
notify
from
zope.exceptions.interfaces
import
UserError
from
zope.i18n.interfaces.locales
import
ICollator
from
zope.i18n.locales.fallbackcollator
import
FallbackCollator
from
zope.interface
import
implements
from
zope.lifecycleevent
import
ObjectCreatedEvent
from
zope.location
import
LocationProxy
from
zope.publisher.browser
import
BrowserView
from
zope.publisher.interfaces
import
IPublishTraverse
from
zope.security.proxy
import
removeSecurityProxy
from
zope.traversing.browser.absoluteurl
import
absoluteURL
import
zope.security.checker
class
Adding
(
BrowserView
):
implements
(
IAdding
,
IPublishTraverse
)
def
add
(
self
,
content
):
"""See zope.app.container.interfaces.IAdding
"""
container
=
self
.
context
name
=
self
.
contentName
chooser
=
INameChooser
(
container
)
# check precondition
checkObject
(
container
,
name
,
content
)
if
IContainerNamesContainer
.
providedBy
(
container
):
# The container picks its own names.
# We need to ask it to pick one.
name
=
chooser
.
chooseName
(
self
.
contentName
or
''
,
content
)
else
:
request
=
self
.
request
name
=
request
.
get
(
'add_input_name'
,
name
)
if
name
is
None
:
name
=
chooser
.
chooseName
(
self
.
contentName
or
''
,
content
)
elif
name
==
''
:
name
=
chooser
.
chooseName
(
''
,
content
)
chooser
.
checkName
(
name
,
content
)
container
[
name
]
=
content
self
.
contentName
=
name
# Set the added object Name
return
container
[
name
]
contentName
=
None
# usually set by Adding traverser
def
nextURL
(
self
):
"""See zope.app.container.interfaces.IAdding"""
return
absoluteURL
(
self
.
context
,
self
.
request
)
+
'/@@contents.html'
# set in BrowserView.__init__
request
=
None
context
=
None
def
publishTraverse
(
self
,
request
,
name
):
"""See zope.publisher.interfaces.IPublishTraverse"""
if
'='
in
name
:
view_name
,
content_name
=
name
.
split
(
"="
,
1
)
self
.
contentName
=
content_name
if
view_name
.
startswith
(
'@@'
):
view_name
=
view_name
[
2
:]
return
getMultiAdapter
((
self
,
request
),
name
=
view_name
)
if
name
.
startswith
(
'@@'
):
view_name
=
name
[
2
:]
else
:
view_name
=
name
view
=
queryMultiAdapter
((
self
,
request
),
name
=
view_name
)
if
view
is
not
None
:
return
view
factory
=
queryUtility
(
IFactory
,
name
)
if
factory
is
None
:
return
super
(
Adding
,
self
).
publishTraverse
(
request
,
name
)
return
factory
def
action
(
self
,
type_name
=
''
,
id
=
''
):
if
not
type_name
:
raise
UserError
(
_
(
u"You must select the type of object to add."
))
if
type_name
.
startswith
(
'@@'
):
type_name
=
type_name
[
2
:]
if
'/'
in
type_name
:
view_name
=
type_name
.
split
(
'/'
,
1
)[
0
]
else
:
view_name
=
type_name
if
queryMultiAdapter
((
self
,
self
.
request
),
name
=
view_name
)
is
not
None
:
url
=
"%s/%s=%s"
%
(
absoluteURL
(
self
,
self
.
request
),
type_name
,
id
)
self
.
request
.
response
.
redirect
(
url
)
return
if
not
self
.
contentName
:
self
.
contentName
=
id
# TODO: If the factory wrapped by LocationProxy is already a Proxy,
# then ProxyFactory does not do the right thing and the
# original's checker info gets lost. No factory that was
# registered via ZCML and was used via addMenuItem worked
# here. (SR)
factory
=
getUtility
(
IFactory
,
type_name
)
if
not
type
(
factory
)
is
zope
.
security
.
checker
.
Proxy
:
factory
=
LocationProxy
(
factory
,
self
,
type_name
)
factory
=
zope
.
security
.
checker
.
ProxyFactory
(
factory
)
content
=
factory
()
# Can't store security proxies.
# Note that it is important to do this here, rather than
# in add, otherwise, someone might be able to trick add
# into unproxying an existing object,
content
=
removeSecurityProxy
(
content
)
notify
(
ObjectCreatedEvent
(
content
))
self
.
add
(
content
)
self
.
request
.
response
.
redirect
(
self
.
nextURL
())
def
nameAllowed
(
self
):
"""Return whether names can be input by the user."""
return
not
IContainerNamesContainer
.
providedBy
(
self
.
context
)
menu_id
=
None
index
=
ViewPageTemplateFile
(
"add.pt"
)
def
addingInfo
(
self
):
"""Return menu data.
This is sorted by title.
"""
container
=
self
.
context
result
=
[]
for
menu_id
in
(
self
.
menu_id
,
'zope.app.container.add'
):
if
not
menu_id
:
continue
for
item
in
getMenu
(
menu_id
,
self
,
self
.
request
):
extra
=
item
.
get
(
'extra'
)
if
extra
:
factory
=
extra
.
get
(
'factory'
)
if
factory
:
factory
=
getUtility
(
IFactory
,
factory
)
if
not
checkFactory
(
container
,
None
,
factory
):
continue
elif
item
[
'extra'
][
'factory'
]
!=
item
[
'action'
]:
item
[
'has_custom_add_view'
]
=
True
# translate here to have a localized sorting
item
[
'title'
]
=
zope
.
i18n
.
translate
(
item
[
'title'
],
context
=
self
.
request
)
result
.
append
(
item
)
# sort the adding info with a collator instead of a basic unicode sort
collator
=
queryAdapter
(
self
.
request
.
locale
,
ICollator
)
if
collator
is
None
:
collator
=
FallbackCollator
(
self
.
request
.
locale
)
result
.
sort
(
key
=
lambda
x
:
collator
.
key
(
x
[
'title'
]))
return
result
def
isSingleMenuItem
(
self
):
"Return whether there is single menu item or not."
return
len
(
self
.
addingInfo
())
==
1
def
hasCustomAddView
(
self
):
"This should be called only if there is `singleMenuItem` else return 0"
if
self
.
isSingleMenuItem
():
menu_item
=
self
.
addingInfo
()[
0
]
if
'has_custom_add_view'
in
menu_item
:
return
True
return
False
src/zope/container/browser/commontasks.pt
deleted
100644 → 0
View file @
f1f6cc98
<tal:block define="addingInfo context/@@+/addingInfo|nothing"
condition="addingInfo">
<tal:block repeat="info addingInfo"
define="namesRequired context/@@+/nameAllowed">
<div tal:define="oddrow repeat/info/odd;
namesRequired context/@@+/nameAllowed;
has_custom_add_view python:'has_custom_add_view' in info"
tal:attributes="class python:oddrow and 'content even' or 'content odd'"
class="even">
<a href="#"
tal:define="baseurl python:request.getURL(1)"
tal:condition="python: not info['action'].startswith('../')
and namesRequired and not has_custom_add_view"
tal:attributes="
href string:${baseurl}/@@contents.html?type_name=${info/action};
class info/selected"
tal:content="info/title">Folder
</a>
<a href="#"
tal:define="baseurl python:request.getURL(1)"
tal:condition="python: not info['action'].startswith('../')
and (has_custom_add_view or not namesRequired)"
tal:attributes="
href string:${baseurl}/@@+/action.html?type_name=${info/action};
class info/selected"
tal:content="info/title">Folder
</a>
<a href="#"
tal:define="baseurl python:request.getURL(1)"
tal:condition="python: info['action'].startswith('../')"
tal:attributes="
href python: info['action'][3:];
class info/selected"
tal:content="info/title">Folder
</a>
</div>
</tal:block>
</tal:block>
src/zope/container/browser/configure.zcml
deleted
100644 → 0
View file @
f1f6cc98
<zope:configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser">
<page
for="zope.app.container.interfaces.IReadContainer"
name="find.html"
permission="zope.ManageContent"
class="zope.app.container.browser.find.Find"
template="find.pt"
menu="zmi_actions" title="Find" />
<page
for="zope.app.container.interfaces.IWriteContainer"
permission="zope.ManageContent"
name="commonTasks"
class="zope.app.container.browser.contents.Contents"
template="commontasks.pt" />
</zope:configure>
src/zope/container/browser/contents.pt
deleted
100644 → 0
View file @
f1f6cc98
<html
metal:use-macro=
"context/@@standard_macros/view"
i18n:domain=
"zope"
>
<body>
<div
metal:fill-slot=
"body"
>
<div
metal:define-macro=
"contents"
>
<form
name=
"containerContentsForm"
method=
"post"
action=
"."
tal:attributes=
"action request/URL"
tal:define=
"container_contents view/listContentInfo"
>
<input
type=
"hidden"
name=
"type_name"
value=
""
tal:attributes=
"value request/type_name"
tal:condition=
"request/type_name|nothing"
/>
<input
type=
"hidden"
name=
"retitle_id"
value=
""
tal:attributes=
"value request/retitle_id"
tal:condition=
"request/retitle_id|nothing"
/>
<div
class=
"page_error"
tal:condition=
"view/error"
tal:content=
"view/error"
i18n:translate=
""
>
Error message
</div>
<table
id=
"sortable"
class=
"listing"
summary=
"Content listing"
i18n:attributes=
"summary"
>
<thead>
<tr>
<th><input
type=
"checkbox"
onchange=
"updateCheckboxes(this, 'slaveBox');"
/></th>
<th
i18n:translate=
""
>
Name
</th>
<th
i18n:translate=
""
>
Title
</th>
<th
i18n:translate=
""
>
Size
</th>
<th
i18n:translate=
""
>
Created
</th>
<th
i18n:translate=
""
>
Modified
</th>
</tr>
</thead>
<tbody>
<metal:block
tal:condition=
"view/hasAdding"
>
<tr
tal:define=
"names_required context/@@+/nameAllowed"
tal:condition=
"python:names_required and request.has_key('type_name')"
>
<td></td>
<td><input
name=
"new_value"
id=
"focusid"
value=
""
/></td>
<td></td>
<td></td>
<td></td>
</tr>
</metal:block>
<metal:block
tal:define=
"supportsRename view/supportsRename"
tal:repeat=
"item container_contents"
>
<tr
tal:define=
"oddrow repeat/item/odd; url item/url;
id_quoted item/id/url:quote"
tal:attributes=
"class python:oddrow and 'even' or 'odd'"
>
<td>
<input
type=
"checkbox"
class=
"noborder slaveBox"
name=
"ids:list"
id=
"#"
value=
"#"
tal:attributes=
"value item/id;
id item/cb_id;
checked request/ids_checked|nothing;"
/>
</td>
<td><a
href=
"#"
tal:attributes=
"href
string:${url}/@@SelectedManagementView.html"
tal:content=
"structure item/icon|default"
>
</a
><span
tal:condition=
"item/rename"
><input
name=
"new_value:list"
tal:attributes=
"value item/id"
/><input
type=
"hidden"
name=
"rename_ids:list"
value=
""
tal:attributes=
"value item/rename"
/></span
><span
tal:condition=
"not:item/rename"
>
<a
href=
"#"
tal:attributes=
"href
string:${url}/@@SelectedManagementView.html"
tal:content=
"item/id"
>
foo
</a
><a
href=
"#"
tal:attributes=
"href
string:${request/URL}?rename_ids:list=${id_quoted}"
tal:condition=
"supportsRename"
>
</a
></span
></td>
<td>
<input
name=
"new_value"
id=
"focusid"
tal:attributes=
"value item/title|nothing"
tal:condition=
"item/retitle"
/>
<a
href=
"#"
tal:attributes=
"href
string:${request/URL}?retitle_id=${id_quoted}"
tal:condition=
"item/retitleable"
tal:content=
"item/title|default"
i18n:translate=
""
>
</a>
<span
tal:condition=
"item/plaintitle"
tal:content=
"item/title|default"
i18n:translate=
""
>
</span>
</td>
<td><span
tal:content=
"item/size/sizeForDisplay|nothing"
i18n:translate=
""
>
</span></td>
<td><span
tal:define=
"created item/created|default"
tal:content=
"created"
i18n:translate=
""
>
</span></td>
<td><span
tal:define=
"modified item/modified|default"
tal:content=
"modified"
i18n:translate=
""
>
</span></td>
</tr>
</metal:block>
</tbody>
</table>
<tal:block
tal:condition=
"view/normalButtons"
>
<input
type=
"submit"
name=
"container_rename_button"
value=
"Rename"
i18n:attributes=
"value container-rename-button"
tal:condition=
"view/supportsRename"
/>
<input
type=
"submit"
name=
"container_cut_button"
value=
"Cut"
i18n:attributes=
"value container-cut-button"
tal:condition=
"view/supportsCut"
/>
<input
type=
"submit"
name=
"container_copy_button"
value=
"Copy"
i18n:attributes=
"value container-copy-button"
tal:condition=
"view/supportsCopy"
/>
<input
type=
"submit"
name=
"container_paste_button"
value=
"Paste"
tal:condition=
"view/hasClipboardContents"
i18n:attributes=
"value container-paste-button"
/>
<input
type=
"submit"
name=
"container_delete_button"
value=
"Delete"
i18n:attributes=
"value container-delete-button"
tal:condition=
"view/supportsDelete"
i18n:domain=
"zope"
/>
<div
tal:condition=
"view/hasAdding"
tal:omit-tag=
""
>
<div
tal:omit-tag=
""
tal:define=
"adding nocall:context/@@+;
addingInfo adding/addingInfo;
has_custom_add_view adding/hasCustomAddView;
names_required adding/nameAllowed"
tal:condition=
"adding/isSingleMenuItem"
>
<input
type=
"submit"
name=
"container_add_button"
value=
"Add"
i18n:attributes=
"value add-button"
i18n:domain=
"zope"
/>
<input
type=
"text"
name=
"single_new_value"
id=
"focusid"
tal:condition=
"python:names_required and not has_custom_add_view"
i18n:domain=
"zope"
/>
<input
type=
"hidden"
name=
"single_type_name"
value=
""
tal:attributes=
"value python:addingInfo[0]['action']"
/>
</div>
</div>
</tal:block>
<div
tal:condition=
"view/specialButtons"
>
<input
type=
"submit"
value=
"Apply"
i18n:attributes=
"value container-apply-button"
/>
<input
type=
"submit"
name=
"container_cancel_button"
value=
"Cancel"
i18n:attributes=
"value container-cancel-button"
/>
</div>
</form>
<script
type=
"text/javascript"
>
<!--
if
(
document
.
containerContentsForm
.
new_value
)
document
.
containerContentsForm
.
new_value
.
focus
();
//-->
</script>
</div>
</div>
</body>
</html>
src/zope/container/browser/contents.py
deleted
100644 → 0
View file @
f1f6cc98
This diff is collapsed.
Click to expand it.
src/zope/container/browser/find.pt
deleted
100644 → 0
View file @
f1f6cc98
<html
metal:use-macro=
"context/@@standard_macros/dialog"
i18n:domain=
"zope"
>
<body>
<div
metal:fill-slot=
"body"
>
<form
action=
"@@find.html"
method=
"get"
>
<input
type=
"text"
name=
"ids"
value=
""
/><br
/>
<input
type=
"submit"
name=
"find_submit"
value=
" Find "
i18n:attributes=
"value find-button"
/>
</form>
<table
tal:condition=
"request/ids|nothing"
>
<tr
tal:repeat=
"item python:view.findByIds(request['ids'])"
>
<td>
<a
href=
""
tal:attributes=
"href item/url"
tal:content=
"item/id"
>
id
</a>
</td>
</tr>
</table>
</div>
</body>
</html>
src/zope/container/browser/find.py
deleted
100644 → 0
View file @
f1f6cc98
##############################################################################
#
# Copyright (c) 2001, 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.
# 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.
#
##############################################################################
"""Find View Class
$Id$
"""
__docformat__
=
'restructuredtext'
from
zope.traversing.api
import
getName
from
zope.traversing.browser.absoluteurl
import
absoluteURL
from
zope.publisher.browser
import
BrowserView
from
zope.app.container.find
import
SimpleIdFindFilter
from
zope.app.container.interfaces
import
IFind
# Very simple implementation right now
class
Find
(
BrowserView
):
def
findByIds
(
self
,
ids
):
"""Do a find for the `ids` listed in `ids`, which is a string."""
finder
=
IFind
(
self
.
context
)
ids
=
ids
.
split
()
# if we don't have any ids listed, don't search at all
if
not
ids
:
return
[]
request
=
self
.
request
result
=
[]
for
object
in
finder
.
find
([
SimpleIdFindFilter
(
ids
)]):
url
=
absoluteURL
(
object
,
request
)
result
.
append
({
'id'
:
getName
(
object
),
'url'
:
url
})
return
result
src/zope/container/browser/index.pt
deleted
100644 → 0
View file @
f1f6cc98
<html
metal:use-macro=
"context/@@standard_macros/page"
i18n:domain=
"zope"
>
<head>
<style
metal:fill-slot=
"headers"
type=
"text/css"
>
<!
--
.ContentIcon
{
width
:
20px
;
}
.ContentTitle
{
text-align
:
left
;
}
--
>
</style>
</head>
<body>
<div
metal:fill-slot=
"body"
>
<table
id=
"sortable"
class=
"listing"
summary=
"Content listing"
cellpadding=
"2"
cellspacing=
"0"
i18n:attributes=
"summary"
>
<thead>
<tr>
<th>
</th>
<th
i18n:translate=
""
>
Name
</th>
<th
i18n:translate=
""
>
Title
</th>
<th
i18n:translate=
""
>
Created
</th>
<th
i18n:translate=
""
>
Modified
</th>
</tr>
</thead>
<tbody>
<tr
tal:repeat=
"info view/listContentInfo"
>
<td>
<a
href=
"#"
tal:attributes=
"href info/url"
tal:content=
"structure info/icon|default"
/>
</td>
<td
class=
"ContentTitle"
>
<a
href=
"subfolder_id"
tal:attributes=
"href info/url"
tal:content=
"info/id"
i18n:translate=
""
>
ID here
</a>
</td>
<td><span
tal:content=
"info/title|default"
i18n:translate=
""
>
</span></td>
<td><span
tal:content=
"info/created|default"
i18n:translate=
""
>
</span></td>
<td><span
tal:content=
"info/modified|default"
i18n:translate=
""
>
</span></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
src/zope/container/browser/meta.zcml
deleted
100644 → 0
View file @
f1f6cc98
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta">
<meta:directives namespace="http://namespaces.zope.org/browser">
<!-- browser cotainer views -->
<meta:directive
name="containerViews"
schema=".metaconfigure.IContainerViews"
handler=".metaconfigure.containerViews"
/>
</meta:directives>
</configure>
\ No newline at end of file
src/zope/container/browser/metaconfigure.py
deleted
100644 → 0
View file @
f1f6cc98
##############################################################################
#
# Copyright (c) 2001, 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.
# 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.
#
##############################################################################
"""Container-specific browser ZCML namespace directive handlers
$Id$
"""
__docformat__
=
'restructuredtext'
from
zope.interface
import
Interface
from
zope.configuration.fields
import
GlobalObject
,
GlobalInterface
from
zope.publisher.interfaces.browser
import
IDefaultBrowserLayer
from
zope.schema
import
Id
from
zope.security.zcml
import
Permission
from
zope.app.publisher.browser.viewmeta
import
page
,
view
from
zope.app.container.browser.contents
import
Contents
from
zope.app.container.browser.adding
import
Adding
from
zope.app.container.i18n
import
ZopeMessageFactory
as
_
class
IContainerViews
(
Interface
):
"""Define several container views for an `IContainer` implementation."""
for_
=
GlobalObject
(
title
=
u"The declaration this containerViews are for."
,
description
=
u"""
The containerViews will be available for all objects that
provide this declaration.
"""
,
required
=
True
)
contents
=
Permission
(
title
=
u"The permission needed for content page."
,
required
=
False
)
index
=
Permission
(
title
=
u"The permission needed for index page."
,
required
=
False
)
add
=
Permission
(
title
=
u"The permission needed for add page."
,
required
=
False
)
layer
=
GlobalInterface
(
title
=
_
(
"The layer the view is in."
),
description
=
_
(
"""A skin is composed of layers. It is common to put
skin specific views in a layer named after the skin. If the 'layer'
attribute is not supplied, it defaults to 'default'."""
),
required
=
False
)
def
containerViews
(
_context
,
for_
,
contents
=
None
,
add
=
None
,
index
=
None
,
layer
=
IDefaultBrowserLayer
):
"""Set up container views for a given content type."""
if
for_
is
None
:
raise
ValueError
(
"A for interface must be specified."
)
if
contents
is
not
None
:
from
zope.app.menus
import
zmi_views
page
(
_context
,
name
=
'contents.html'
,
permission
=
contents
,
for_
=
for_
,
layer
=
layer
,
class_
=
Contents
,
attribute
=
'contents'
,
menu
=
zmi_views
,
title
=
_
(
'Contents'
))
if
index
is
not
None
:
page
(
_context
,
name
=
'index.html'
,
permission
=
index
,
for_
=
for_
,
layer
=
layer
,
class_
=
Contents
,
attribute
=
'index'
)
if
add
is
not
None
:
from
zope.app.menus
import
zmi_actions
viewObj
=
view
(
_context
,
name
=
'+'
,
layer
=
layer
,
menu
=
zmi_actions
,
title
=
_
(
'Add'
),
for_
=
for_
,
permission
=
add
,
class_
=
Adding
)
viewObj
.
page
(
_context
,
name
=
'index.html'
,
attribute
=
'index'
)
viewObj
.
page
(
_context
,
name
=
'action.html'
,
attribute
=
'action'
)
viewObj
()
src/zope/container/browser/tests/__init__.py
deleted
100644 → 0
View file @
f1f6cc98
#
# This file is necessary to make this directory a package.
src/zope/container/browser/tests/configure.zcml
deleted
100644 → 0
View file @
f1f6cc98
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
<class class=".test_contents_functional.ReadOnlyContainer">
<require
permission="zope.ManageContent"
interface="zope.app.container.interfaces.IReadContainer"
/>
</class>
<browser:containerViews
for="zope.app.container.interfaces.IReadContainer"
contents="zope.ManageContent" />
</configure>
src/zope/container/browser/tests/index.txt
deleted
100644 → 0
View file @
f1f6cc98
The containerViews directive lets us associate some standard forms
for containers with an interface. There's an "index.html" view that
provides a listing of the contained objects without provinding any way
to manage them (though it allows us to visit them by clicking on
links).
We can get this view from the root folder easily::
>>> response = http(r"""
... GET / HTTP/1.1
... """)
And we can check that there isn't a form (where the management
operations would have buttons)::
>>> body = response.getBody().lower()
>>> "<form" in body
False
src/zope/container/browser/tests/test_adding.py
deleted
100644 → 0
View file @
f1f6cc98
This diff is collapsed.
Click to expand it.
src/zope/container/browser/tests/test_contents.py
deleted
100644 → 0
View file @
f1f6cc98
This diff is collapsed.
Click to expand it.
src/zope/container/browser/tests/test_contents_functional.py
deleted
100644 → 0
View file @
f1f6cc98
This diff is collapsed.
Click to expand it.
src/zope/container/browser/tests/test_directive.py
deleted
100644 → 0
View file @
f1f6cc98
This diff is collapsed.
Click to expand it.
src/zope/container/ftesting.zcml
deleted
100644 → 0
View file @
f1f6cc98
<configure
xmlns="http://namespaces.zope.org/zope"
i18n_domain="zope"
package="zope.app.container"
>
<!-- This file is the equivalent of site.zcml and it is -->
<!-- used for functional testing setup -->
<include package="zope.app.zcmlfiles" />
<include package="zope.app.container.browser.tests" />
<include package="zope.app.file"/>
<include package="zope.app.authentication" />
<include package="zope.app.securitypolicy" file="meta.zcml" />
<include package="zope.app.securitypolicy.tests" file="functional.zcml" />
<include package="zope.app.securitypolicy" />
<securityPolicy
component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
<role id="zope.Anonymous" title="Everybody"
description="All users have this role implicitly" />
<role id="zope.Manager" title="Site Manager" />
<!-- Replace the following directive if you don't want public access -->
<grant permission="zope.View"
role="zope.Anonymous" />
<grant permission="zope.app.dublincore.view"
role="zope.Anonymous" />
<grantAll role="zope.Manager" />
<!-- Principals -->
<unauthenticatedPrincipal
id="zope.anybody"
title="Unauthenticated User" />
<!-- Principal that tests generally run as -->
<principal
id="zope.mgr"
title="Manager"
login="mgr"
password="mgrpw" />
<!-- Bootstrap principal used to make local grant to the principal above -->
<principal
id="zope.globalmgr"
title="Manager"
login="globalmgr"
password="globalmgrpw" />
<grant role="zope.Manager" principal="zope.globalmgr" />
</configure>
src/zope/container/tests/test_view_permissions.py
deleted
100644 → 0
View file @
f1f6cc98
##############################################################################
#
# Copyright (c) 2004 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.
#
##############################################################################
"""Container View Permissions Tests
$Id$
"""
import
unittest
import
transaction
from
zope.security.interfaces
import
Unauthorized
from
zope.app.testing.functional
import
BrowserTestCase
from
zope.app.file
import
File
from
zope.dublincore.interfaces
import
IZopeDublinCore
from
zope.securitypolicy.interfaces
import
IRolePermissionManager
from
zope.app.container.testing
import
AppContainerLayer
class
Tests
(
BrowserTestCase
):
def
test_default_view_permissions
(
self
):
"""Tests the default view permissions.
See zope/app/securitypolicy/configure.zcml for the grants of
zope.View and zope.app.dublincore.view to zope.Anonymous. These
ensure that, by default, anonymous users can view container contents.
"""
# add an item that can be viewed from the root folder
file
=
File
()
self
.
getRootFolder
()[
'file'
]
=
file
IZopeDublinCore
(
file
).
title
=
u'My File'
transaction
.
commit
()
response
=
self
.
publish
(
'/'
)
self
.
assertEquals
(
response
.
getStatus
(),
200
)
body
=
response
.
getBody
()
# confirm we can see the file name
self
.
assert_
(
body
.
find
(
'<a href="file">file</a>'
)
!=
-
1
)
# confirm we can see the metadata title
self
.
assert_
(
body
.
find
(
'<td><span>My File</span></td>'
)
!=
-
1
)
def
test_deny_view
(
self
):
"""Tests the denial of view permissions to anonymous.
This test uses the ZMI interface to deny anonymous zope.View permission
to the root folder.
"""
# deny zope.View to zope.Anonymous
prm
=
IRolePermissionManager
(
self
.
getRootFolder
())
prm
.
denyPermissionToRole
(
'zope.View'
,
'zope.Anonymous'
)
transaction
.
commit
()
# confirm Unauthorized when viewing root folder
self
.
assertRaises
(
Unauthorized
,
self
.
publish
,
'/'
)
def
test_deny_dublincore_view
(
self
):
"""Tests the denial of dublincore view permissions to anonymous.
Users who can view a folder contents page but cannot view dublin core
should still be able to see the folder items' names, but not their
title, modified, and created info.
"""
# add an item that can be viewed from the root folder
file
=
File
()
self
.
getRootFolder
()[
'file'
]
=
file
IZopeDublinCore
(
file
).
title
=
u'My File'
# deny zope.app.dublincore.view to zope.Anonymous
prm
=
IRolePermissionManager
(
self
.
getRootFolder
())
prm
.
denyPermissionToRole
(
'zope.app.dublincore.view'
,
'zope.Anonymous'
)
transaction
.
commit
()
response
=
self
.
publish
(
'/'
)
self
.
assertEquals
(
response
.
getStatus
(),
200
)
body
=
response
.
getBody
()
# confirm we can see the file name
self
.
assert_
(
body
.
find
(
'<a href="file">file</a>'
)
!=
-
1
)
# confirm we *cannot* see the metadata title
self
.
assert_
(
body
.
find
(
'My File'
)
==
-
1
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
Tests
.
layer
=
AppContainerLayer
suite
.
addTest
(
unittest
.
makeSuite
(
Tests
))
return
suite
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
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