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
b0c70bdd
Commit
b0c70bdd
authored
Jul 10, 2012
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- now we can simplify that code a bit
parent
a4485bbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
25 deletions
+16
-25
src/Products/Five/browser/metaconfigure.py
src/Products/Five/browser/metaconfigure.py
+16
-25
No files found.
src/Products/Five/browser/metaconfigure.py
View file @
b0c70bdd
...
...
@@ -120,38 +120,29 @@ def page(_context, name, permission, for_=Interface,
raise
ConfigurationError
(
"The provided class doesn't have the specified attribute "
)
cdict
=
getSecurityInfo
(
class_
)
cdict
[
'__name__'
]
=
name
if
template
:
# class and template
new_class
=
SimpleViewClass
(
template
,
bases
=
(
class_
,
),
name
=
name
)
elif
attribute
!=
"__call__"
:
# we're supposed to make a page for an attribute (read:
# method) and it's not __call__. We thus need to create a
# new class using our mixin for attributes.
cdict
[
'__page_attribute__'
]
=
attribute
new_class
=
makeClass
(
class_
.
__name__
,
(
class_
,
simple
),
cdict
)
# in case the attribute does not provide a docstring,
# ZPublisher refuses to publish it. So, as a workaround,
# we provide a stub docstring
func
=
getattr
(
new_class
,
attribute
)
if
not
func
.
__doc__
:
# cannot test for MethodType/UnboundMethod here
# because of ExtensionClass
if
hasattr
(
func
,
'im_func'
):
# you can only set a docstring on functions, not
# on method objects
func
=
func
.
im_func
func
.
__doc__
=
"Stub docstring to make ZPublisher work"
else
:
# we could use the class verbatim here, but we'll execute
# some security declarations on it so we really shouldn't
# modify the original. So, instead we make a new class
# with just one base class -- the original
cdict
=
getSecurityInfo
(
class_
)
cdict
[
'__name__'
]
=
name
cdict
[
'__page_attribute__'
]
=
attribute
new_class
=
makeClass
(
class_
.
__name__
,
(
class_
,
simple
),
cdict
)
if
attribute
!=
"__call__"
:
# in case the attribute does not provide a docstring,
# ZPublisher refuses to publish it. So, as a workaround,
# we provide a stub docstring
func
=
getattr
(
new_class
,
attribute
)
if
not
func
.
__doc__
:
# cannot test for MethodType/UnboundMethod here
# because of ExtensionClass
if
hasattr
(
func
,
'im_func'
):
# you can only set a docstring on functions, not
# on method objects
func
=
func
.
im_func
func
.
__doc__
=
"Stub docstring to make ZPublisher work"
else
:
# template
new_class
=
SimpleViewClass
(
template
,
name
=
name
)
...
...
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