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
0502ac62
Commit
0502ac62
authored
Jul 27, 2007
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Death to __of__!
parent
22f2299a
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
18 additions
and
42 deletions
+18
-42
lib/python/OFS/Traversable.py
lib/python/OFS/Traversable.py
+2
-2
lib/python/Products/Five/browser/metaconfigure.py
lib/python/Products/Five/browser/metaconfigure.py
+3
-3
lib/python/Products/Five/browser/providerexpression.py
lib/python/Products/Five/browser/providerexpression.py
+0
-5
lib/python/Products/Five/browser/resource.py
lib/python/Products/Five/browser/resource.py
+3
-9
lib/python/Products/Five/browser/tests/pages.txt
lib/python/Products/Five/browser/tests/pages.txt
+0
-1
lib/python/Products/Five/form/objectwidget.py
lib/python/Products/Five/form/objectwidget.py
+5
-12
lib/python/Products/Five/viewlet/manager.py
lib/python/Products/Five/viewlet/manager.py
+0
-5
lib/python/ZPublisher/BaseRequest.py
lib/python/ZPublisher/BaseRequest.py
+5
-5
No files found.
lib/python/OFS/Traversable.py
View file @
0502ac62
...
...
@@ -192,7 +192,7 @@ class Traversable:
if
ns
:
try
:
next
=
namespaceLookup
(
ns
,
nm
,
obj
,
self
.
REQUEST
)
.
__of__
(
obj
)
ns
,
nm
,
obj
,
self
.
REQUEST
)
if
restricted
and
not
validate
(
obj
,
obj
,
name
,
next
):
raise
Unauthorized
(
name
)
...
...
@@ -260,7 +260,7 @@ class Traversable:
Interface
,
name
)
if
next
is
not
None
:
next
=
next
.
__of__
(
obj
)
next
=
next
if
restricted
and
not
validate
(
obj
,
obj
,
name
,
next
):
raise
Unauthorized
(
name
)
elif
bobo_traverse
is
not
None
:
...
...
lib/python/Products/Five/browser/metaconfigure.py
View file @
0502ac62
...
...
@@ -209,9 +209,9 @@ class view(zope_app_view):
view
=
component
.
queryMultiAdapter
((
self
,
request
),
name
=
name
,
default
=
None
)
if
view
is
not
None
:
return
view
.
__of__
(
self
)
return
view
m
=
class_
.
publishTraverse
.
__get__
(
self
)
.
__of__
(
self
)
m
=
class_
.
publishTraverse
.
__get__
(
self
)
return
m
(
request
,
name
)
else
:
...
...
@@ -223,7 +223,7 @@ class view(zope_app_view):
view
=
component
.
queryMultiAdapter
((
self
,
request
),
name
=
name
,
default
=
None
)
if
view
is
not
None
:
return
view
.
__of__
(
self
)
return
view
raise
NotFoundError
(
self
,
name
,
request
)
...
...
lib/python/Products/Five/browser/providerexpression.py
View file @
0502ac62
...
...
@@ -41,11 +41,6 @@ class Z2ProviderExpression(StringExpr):
if
provider
is
None
:
raise
cp_interfaces
.
ContentProviderLookupError
(
name
)
# Wrap the content provider's in its __parent__, whatever that
# may be (typically the view).
if
getattr
(
provider
,
'__of__'
,
None
)
is
not
None
:
provider
=
provider
.
__of__
(
provider
.
__parent__
)
# Insert the data gotten from the context
addTALNamespaceData
(
provider
,
econtext
)
...
...
lib/python/Products/Five/browser/resource.py
View file @
0502ac62
...
...
@@ -18,7 +18,6 @@ $Id$
import
os
import
urllib
import
Acquisition
from
OFS.Traversable
import
Traversable
as
OFSTraversable
from
zope.app.publisher.browser.resources
import
empty
from
zope.app.publisher.fileresource
import
File
,
Image
...
...
@@ -28,12 +27,11 @@ from zope.component import getMultiAdapter
from
zope.component.interfaces
import
IResource
from
zope.datetime
import
time
as
timeFromDateTimeString
from
zope.traversing.browser.interfaces
import
IAbsoluteURL
from
Products.Five.browser
import
BrowserView
_marker
=
[]
class
Resource
(
Acquisition
.
Explici
t
):
class
Resource
(
objec
t
):
"""A publishable resource
"""
implements
(
IResource
)
...
...
@@ -63,7 +61,7 @@ class PageTemplateResource(BrowserView, Resource):
"""Rendered content"""
# ZPublisher might have called setBody with an incorrect URL
# we definitely don't want that if we are plain html
self
.
request
.
RESPONSE
.
setBase
(
None
)
self
.
request
.
response
.
setBase
(
None
)
pt
=
self
.
context
return
pt
(
self
.
request
)
...
...
@@ -229,11 +227,7 @@ class DirectoryResource(BrowserView, Resource, OFSTraversable):
resource
=
factory
(
name
,
filename
)(
self
.
request
)
resource
.
__name__
=
name
resource
.
__parent__
=
self
# XXX __of__ wrapping is usually done on traversal.
# However, we don't want to subclass Traversable (or do we?)
# The right thing should probably be a specific (and very simple)
# traverser that does __getitem__ and __of__.
return
resource
.
__of__
(
self
)
return
resource
class
DirectoryResourceFactory
(
ResourceFactory
):
...
...
lib/python/Products/Five/browser/tests/pages.txt
View file @
0502ac62
...
...
@@ -221,7 +221,6 @@ so we get ('',) instead of ('eagle',):
Wrap into an acquisition so that imPermissionRole objects can be
evaluated. __roles__ is a imPermissionRole object:
>>> view = view.__of__(self.folder.testoid)
>>> view_roles = getattr(view, '__roles__', None)
>>> view_roles
('Manager',)
...
...
lib/python/Products/Five/form/objectwidget.py
View file @
0502ac62
...
...
@@ -22,23 +22,20 @@ ZopeTwoPageTemplateFile with the proper acquisition context.
$Id$
"""
import
Acquisition
import
zope.app.form.browser.objectwidget
from
AccessControl
import
ClassSecurityInfo
from
Globals
import
InitializeClass
as
initializeClass
from
Products.Five.browser.pagetemplatefile
import
ZopeTwo
PageTemplateFile
from
Products.Five.browser.pagetemplatefile
import
View
PageTemplateFile
class
ObjectWidgetView
(
Acquisition
.
Explicit
,
zope
.
app
.
form
.
browser
.
objectwidget
.
ObjectWidgetView
):
class
ObjectWidgetView
(
zope
.
app
.
form
.
browser
.
objectwidget
.
ObjectWidgetView
):
security
=
ClassSecurityInfo
()
security
.
declareObjectPublic
()
template
=
ZopeTwo
PageTemplateFile
(
'objectwidget.pt'
)
template
=
View
PageTemplateFile
(
'objectwidget.pt'
)
initializeClass
(
ObjectWidgetView
)
class
ObjectWidgetClass
(
Acquisition
.
Explicit
,
zope
.
app
.
form
.
browser
.
objectwidget
.
ObjectWidget
):
class
ObjectWidgetClass
(
zope
.
app
.
form
.
browser
.
objectwidget
.
ObjectWidget
):
def
__init__
(
self
,
context
,
request
,
factory
,
**
kw
):
super
(
ObjectWidgetClass
,
self
).
__init__
(
context
,
request
,
factory
,
**
kw
)
...
...
@@ -58,8 +55,4 @@ class ObjectWidgetClass(Acquisition.Explicit,
val
=
self
.
context
.
schema
[
name
].
default
self
.
getSubWidget
(
name
).
setRenderedValue
(
val
)
def
ObjectWidget
(
context
,
request
,
factory
,
**
kw
):
"""Return an ObjectWidget suitable in the Five environment, with
right acquisition context"""
return
ObjectWidgetClass
(
context
,
request
,
factory
,
**
kw
).
__of__
(
context
.
context
)
ObjectWidget
=
ObjectWidetClass
lib/python/Products/Five/viewlet/manager.py
View file @
0502ac62
...
...
@@ -41,9 +41,6 @@ class ViewletManagerBase(origManagerBase, Acquisition.Explicit):
raise
zope
.
component
.
interfaces
.
ComponentLookupError
(
'No provider with name `%s` found.'
%
name
)
# Wrap the viewlet for security lookups
viewlet
=
viewlet
.
__of__
(
viewlet
.
context
)
# If the viewlet cannot be accessed, then raise an
# unauthorized error
if
not
guarded_hasattr
(
viewlet
,
'render'
):
...
...
@@ -65,8 +62,6 @@ class ViewletManagerBase(origManagerBase, Acquisition.Explicit):
# the object has a real context from which to determine owner
# security.
for
name
,
viewlet
in
viewlets
:
if
getattr
(
viewlet
,
'__of__'
,
None
)
is
not
None
:
viewlet
=
viewlet
.
__of__
(
viewlet
.
__parent__
)
if
guarded_hasattr
(
viewlet
,
'render'
):
results
.
append
((
name
,
viewlet
))
return
results
...
...
lib/python/ZPublisher/BaseRequest.py
View file @
0502ac62
...
...
@@ -95,7 +95,7 @@ class DefaultPublishTraverse(object):
request
.
response
.
setStatus
(
200
)
# We don't need to do the docstring security check
# for views, so lets skip it and return the object here.
return
subobject
.
__of__
(
object
)
return
subobject
# No view found. Reraise the error raised by __bobo_traverse__
raise
e
else
:
...
...
@@ -105,9 +105,10 @@ class DefaultPublishTraverse(object):
subobject
=
getattr
(
object
,
name
)
else
:
# We try to fall back to a view:
subobject
=
queryMultiAdapter
((
object
,
request
),
Interface
,
name
)
subobject
=
queryMultiAdapter
((
object
,
request
),
Interface
,
name
)
if
subobject
is
not
None
:
return
subobject
.
__of__
(
object
)
return
subobject
# And lastly, of there is no view, try acquired attributes, but
# only if there is no __bobo_traverse__:
...
...
@@ -311,8 +312,7 @@ class BaseRequest:
ob2
=
namespaceLookup
(
ns
,
nm
,
ob
,
self
)
except
TraversalError
:
raise
KeyError
(
ob
,
name
)
return
ob2
.
__of__
(
ob
)
return
ob2
if
name
==
'.'
:
return
ob
...
...
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