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
b8c4aeaa
Commit
b8c4aeaa
authored
Jul 13, 2011
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using id() methods and define proper getId methods
parent
c8b7bcbe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
19 deletions
+9
-19
src/OFS/Application.py
src/OFS/Application.py
+1
-1
src/OFS/Image.py
src/OFS/Image.py
+0
-3
src/OFS/SimpleItem.py
src/OFS/SimpleItem.py
+5
-12
src/OFS/tests/testApplication.py
src/OFS/tests/testApplication.py
+3
-3
No files found.
src/OFS/Application.py
View file @
b8c4aeaa
...
...
@@ -82,7 +82,7 @@ class Application(ApplicationDefaultPermissions,
self
.
__allow_groups__
=
uf
self
.
_setObject
(
'acl_users'
,
uf
)
def
i
d
(
self
):
def
getI
d
(
self
):
try
:
return
self
.
REQUEST
[
'SCRIPT_NAME'
][
1
:]
except
(
KeyError
,
TypeError
):
...
...
src/OFS/Image.py
View file @
b8c4aeaa
...
...
@@ -141,9 +141,6 @@ class File(Persistent, Implicit, PropertyManager,
content_type
=
self
.
_get_content_type
(
file
,
data
,
id
,
content_type
)
self
.
update_data
(
data
,
content_type
,
size
)
def
id
(
self
):
return
self
.
__name__
def
_if_modified_since_request_handler
(
self
,
REQUEST
,
RESPONSE
):
# HTTP If-Modified-Since header handling: return True if
# we can handle this request by returning a 304 response
...
...
src/OFS/SimpleItem.py
View file @
b8c4aeaa
...
...
@@ -91,7 +91,7 @@ class Item(Base,
manage_afterClone
.
__five_method__
=
True
# Direct use of the 'id' attribute is deprecated - use getId()
id
=
''
id
=
''
security
.
declarePublic
(
'getId'
)
def
getId
(
self
):
...
...
@@ -100,17 +100,13 @@ class Item(Base,
This method should be used in preference to accessing an id attribute
of an object directly. The getId method is public.
"""
name
=
getattr
(
self
,
'id'
,
None
)
if
callable
(
name
):
return
name
()
name
=
self
.
id
if
name
is
not
None
:
return
name
if
hasattr
(
self
,
'__name__'
):
return
self
.
__name__
raise
AttributeError
,
'This object has no id'
return
self
.
__name__
# Alias id to __name__, which will make tracebacks a good bit nicer:
__name__
=
ComputedAttribute
(
lambda
self
:
self
.
getId
()
)
__name__
=
ComputedAttribute
(
lambda
self
:
self
.
id
)
# Meta type used for selecting all objects of a given type.
meta_type
=
'simple item'
...
...
@@ -377,7 +373,6 @@ InitializeClass(Item)
class
Item_w__name__
(
Item
):
"""Mixin class to support common name/id functions"""
implements
(
IItemWithName
)
...
...
@@ -411,12 +406,10 @@ class Item_w__name__(Item):
getPhysicalRoot() and getPhysicalPath() are designed to operate
together.
"""
path
=
(
self
.
__name__
,)
path
=
(
self
.
__name__
,
)
p
=
aq_parent
(
aq_inner
(
self
))
if
p
is
not
None
:
path
=
p
.
getPhysicalPath
()
+
path
return
path
...
...
src/OFS/tests/testApplication.py
View file @
b8c4aeaa
...
...
@@ -29,17 +29,17 @@ class ApplicationTests(unittest.TestCase):
def
test_id_no_request
(
self
):
app
=
self
.
_makeOne
()
self
.
assertEqual
(
app
.
i
d
(),
'Zope'
)
self
.
assertEqual
(
app
.
getI
d
(),
'Zope'
)
def
test_id_w_request_no_SCRIPT_NAME
(
self
):
app
=
self
.
_makeOne
()
app
.
REQUEST
=
{}
self
.
assertEqual
(
app
.
i
d
(),
'Zope'
)
self
.
assertEqual
(
app
.
getI
d
(),
'Zope'
)
def
test_id_w_request_w_SCRIPT_NAME
(
self
):
app
=
self
.
_makeOne
()
app
.
REQUEST
=
{
'SCRIPT_NAME'
:
'/Dummy'
}
self
.
assertEqual
(
app
.
i
d
(),
'Dummy'
)
self
.
assertEqual
(
app
.
getI
d
(),
'Dummy'
)
def
test_title_and_id_plus_title_or_id
(
self
):
app
=
self
.
_makeOne
()
...
...
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