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
8e064df5
Commit
8e064df5
authored
Oct 10, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various bug fixes made while preparing the Bobo course.
parent
4fff45ca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
66 deletions
+20
-66
lib/python/ZPublisher/Publish.py
lib/python/ZPublisher/Publish.py
+20
-66
No files found.
lib/python/ZPublisher/Publish.py
View file @
8e064df5
...
@@ -16,8 +16,7 @@ Benefits
...
@@ -16,8 +16,7 @@ Benefits
web server.
web server.
- Applications can be moved from one publishing mechanism, such as
- Applications can be moved from one publishing mechanism, such as
CGI, to another mechanism, such as Fast CGI or ILU Requestor, with
CGI, to another mechanism, such as Fast CGI or COM, with no change.
no change.
- Python objects are published as Python objects. The web server
- Python objects are published as Python objects. The web server
"calls" the objects in much the same way that other Python objects
"calls" the objects in much the same way that other Python objects
...
@@ -49,14 +48,6 @@ Published objects
...
@@ -49,14 +48,6 @@ Published objects
are published.
are published.
Alternatively, a module variable, named 'web_objects' can be
defined. If this variable is defined, it should be bound to a
mapping object that maps published names to published objects.
Objects that are published through a module's 'web_objects' are not
subject to the restrictions listed above. For example, modules or
objects without documentation strings may be published by including
them in a module's 'web_objects' attribute.
Sub-objects (or sub-sub objects, ...) of published objects are
Sub-objects (or sub-sub objects, ...) of published objects are
also published, as long as the sub-objects:
also published, as long as the sub-objects:
...
@@ -66,12 +57,6 @@ Published objects
...
@@ -66,12 +57,6 @@ Published objects
- are not modules.
- are not modules.
A sub-object that cannot have a doc strings may be published by
including a special attribute in the containing object named:
subobject_name__doc__. For example, if foo.bar.spam doesn't have a
doc string, but foo.bar has a non-empty attribute
foo.bar.spam__doc__, then foo.bar.spam can be published.
Note that object methods are considered to be subobjects.
Note that object methods are considered to be subobjects.
Object-to-subobject traversal is done by converting steps in the URI
Object-to-subobject traversal is done by converting steps in the URI
...
@@ -86,26 +71,14 @@ Published objects
...
@@ -86,26 +71,14 @@ Published objects
fails, then the object publisher raises a '"Not Found"' exception. If
fails, then the object publisher raises a '"Not Found"' exception. If
either of the accesses suceeds, then, of course, processing continues.
either of the accesses suceeds, then, of course, processing continues.
Normally, URL traversal begins with the published module. If the
Published module has a global variable named 'bobo_application',
then traversal begins with this object instead.
If the final object encountered when traversing the URL has an
If the final object encountered when traversing the URL has an
'index_html' attribute, the object traversal will continue to this
'index_html' attribute, the object traversal will continue to this
attribute. This is useful for providing default methods for objects.
attribute. This is useful for providing default methods for objects.
In some cases, a parent object may hold special attributed for a
subobject. This may be the case either when a sub-object cannot have
the special attribute or when it is convenience for the parent
object to manage attribute data (e.g. to share attribute data among
multiple children). When the object publisher looks for a special
attribute, it first trys to get the attribute from the published
object. If it fails to get the special attribute, it uses the same
access mechanism used to extract the subobject from the parent
object to get an attribute (or item) using a name obtained by
concatinating the sub-object name with the special attribute
name. For example, let 'foo.bar' be a dictionary, and foo.bar.spam
an item in the dictionary. When attempting to obtain the special
attribute '__roles__', the object publisher will first try to
evaluate 'foo.bar.spam.__roles__', and then try to evaluate:
'foo.bar["spam"+"__roles__"]'.
Access Control
Access Control
Access to an object (and it's sub-objects) may be further restricted
Access to an object (and it's sub-objects) may be further restricted
...
@@ -114,19 +87,14 @@ Access Control
...
@@ -114,19 +87,14 @@ Access Control
The '__allow_groups__' attribute may be a mapping object, in which
The '__allow_groups__' attribute may be a mapping object, in which
case it is a collection of named groups. Alternatively, the
case it is a collection of named groups. Alternatively, the
'__allow_groups__' attribute may be a sequence, in which case it is
'__allow_groups__' attribute may be a sequence, in which case it is
a collection of named groups. Each group must be a dictionary that
a collection of unnamed groups. Each group must be a mapping from
use names as keys (i.e. sets of names). The values in these
name to password.
dictionaries may contain passwords for authenticating each of the
names. The basic authentication realm name used is
'module_name.server_name', where 'module_name' is the name of the
module containing the published objects, and server_name is the name
of the web server.
The module used to publish an object may contain it's own
The module used to publish an object may contain it's own
'__allow_groups__' attribute, thereby limiting access to all of the
'__allow_groups__' attribute, thereby limiting access to all of the
objects in a module.
objects in a module.
If multiple objects in the UR
I
path have '__allow_groups__'
If multiple objects in the UR
L
path have '__allow_groups__'
attributes, then the '__allow_groups__' attribute from the last
attributes, then the '__allow_groups__' attribute from the last
object in the path that has this attribute will be used. The
object in the path that has this attribute will be used. The
'__allow_groups__' attribute for a subobject overides
'__allow_groups__' attribute for a subobject overides
...
@@ -276,17 +244,9 @@ Return types
...
@@ -276,17 +244,9 @@ Return types
will be set to 'text/html'. Otherwise the content-type will be set
will be set to 'text/html'. Otherwise the content-type will be set
to 'text/plain'.
to 'text/plain'.
A special case is when the returned object is a two-element tuple.
If the return object is a two-element tuple, then the first element
will be converted to a string and treated as an HTML title, and
the second element will be converted to a string and treated as
the contents of an HTML body. An HTML document is created and
returned (with type text/html) by adding necessary html, head,
title, and body tags.
If the returned object is None or the string representation of the
If the returned object is None or the string representation of the
returned object is an empty string, then
HTTP the
return status will
returned object is an empty string, then
the HTTP
return status will
be set "No Content", and no body will be returned. On some
be set
to
"No Content", and no body will be returned. On some
browsers, this will cause the displayed document to be unchanged.
browsers, this will cause the displayed document to be unchanged.
Base References
Base References
...
@@ -301,18 +261,6 @@ Base References
...
@@ -301,18 +261,6 @@ Base References
absolute reference will be constructed from the effective URL used
absolute reference will be constructed from the effective URL used
to access the published object and from the relative reference.
to access the published object and from the relative reference.
Providing On-Line help
On-line help is provided for published objects, both explicitly and
implicitly. To provide on-line help for an object, simply provide a
'help' attribute for the object. If a 'help' attribute is not
provided, then the object's documentation string is used. When a URI
like: 'http:/some.server/cgi-bin/some_module/foo/bar/help' is
presented to the publisher, it will try to access the 'help'
attribute of 'some_module.foo.bar'. If the object does not have a
'help' attribute, then the object's documentation string will be
returned.
Exception handling
Exception handling
Unhandled exceptions are caught by the object publisher
Unhandled exceptions are caught by the object publisher
...
@@ -491,7 +439,7 @@ Publishing a module using Fast CGI
...
@@ -491,7 +439,7 @@ Publishing a module using Fast CGI
o Configure the Fast CGI-enabled web server to execute this
o Configure the Fast CGI-enabled web server to execute this
file.
file.
$Id: Publish.py,v 1.5
5 1997/09/26 19:15:47
jim Exp $"""
$Id: Publish.py,v 1.5
6 1997/10/10 19:34:20
jim Exp $"""
#'
#'
# Copyright
# Copyright
#
#
...
@@ -546,7 +494,7 @@ $Id: Publish.py,v 1.55 1997/09/26 19:15:47 jim Exp $"""
...
@@ -546,7 +494,7 @@ $Id: Publish.py,v 1.55 1997/09/26 19:15:47 jim Exp $"""
# See end of file for change log.
# See end of file for change log.
#
#
##########################################################################
##########################################################################
__version__
=
'$Revision: 1.5
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
6
$'
[
11
:
-
2
]
def
main
():
def
main
():
...
@@ -742,6 +690,7 @@ class ModulePublisher:
...
@@ -742,6 +690,7 @@ class ModulePublisher:
except
:
groups
=
None
except
:
groups
=
None
web_objects
=
None
web_objects
=
None
roles
=
UNSPECIFIED_ROLES
try
:
try
:
object
=
module
.
bobo_application
object
=
module
.
bobo_application
try
:
try
:
...
@@ -749,7 +698,7 @@ class ModulePublisher:
...
@@ -749,7 +698,7 @@ class ModulePublisher:
inherited_groups
.
append
(
groups
)
inherited_groups
.
append
(
groups
)
except
:
groups
=
None
except
:
groups
=
None
try
:
roles
=
object
.
__roles__
try
:
roles
=
object
.
__roles__
except
:
roles
=
UNSPECIFIED_ROLES
except
:
pass
except
:
except
:
try
:
try
:
web_objects
=
module
.
web_objects
web_objects
=
module
.
web_objects
...
@@ -820,11 +769,14 @@ class ModulePublisher:
...
@@ -820,11 +769,14 @@ class ModulePublisher:
method
=
upper
(
request
[
'REQUEST_METHOD'
])
method
=
upper
(
request
[
'REQUEST_METHOD'
])
if
method
==
'GET'
or
method
==
'POST'
:
method
=
'index_html'
if
method
==
'GET'
or
method
==
'POST'
:
method
=
'index_html'
URL
=
self
.
script
# Get default object if no path was specified:
# Get default object if no path was specified:
if
not
path
:
if
not
path
:
entry_name
=
method
entry_name
=
method
try
:
try
:
if
hasattr
(
object
,
entry_name
):
if
hasattr
(
object
,
entry_name
):
response
.
setBase
(
URL
+
'/'
,
''
)
path
=
[
entry_name
]
path
=
[
entry_name
]
else
:
else
:
try
:
try
:
...
@@ -835,7 +787,6 @@ class ModulePublisher:
...
@@ -835,7 +787,6 @@ class ModulePublisher:
if
not
path
:
path
=
[
'help'
]
if
not
path
:
path
=
[
'help'
]
# Traverse the URL to find the object:
# Traverse the URL to find the object:
URL
=
self
.
script
parents
=
[]
parents
=
[]
try
:
# Try to bind the top-level object to the request
try
:
# Try to bind the top-level object to the request
...
@@ -1465,6 +1416,9 @@ def publish_module(module_name,
...
@@ -1465,6 +1416,9 @@ def publish_module(module_name,
#
#
# $Log: Publish.py,v $
# $Log: Publish.py,v $
# Revision 1.56 1997/10/10 19:34:20 jim
# Various bug fixes made while preparing the Bobo course.
#
# Revision 1.55 1997/09/26 19:15:47 jim
# Revision 1.55 1997/09/26 19:15:47 jim
# Added url unquoting of form field names.
# Added url unquoting of form field names.
#
#
...
...
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