-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ObjectManager's
get
and __getitem__
return only "items".
No longer return attributes / methods from the class or from acquisition. Thanks to Richard Mitchell at Netsight for the report.
- Loading branch information
Showing
4 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
import re | ||
import sys | ||
import time | ||
from types import NoneType | ||
|
||
from AccessControl import ClassSecurityInfo | ||
from AccessControl.class_init import InitializeClass | ||
|
@@ -757,12 +758,13 @@ def __delitem__(self, name): | |
return self.manage_delObjects(ids=[name]) | ||
|
||
def __getitem__(self, key): | ||
v=self._getOb(key, None) | ||
if v is not None: return v | ||
if hasattr(self, 'REQUEST'): | ||
request=self.REQUEST | ||
if key in self: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tseaver
Author
Member
|
||
return self._getOb(key, None) | ||
request = getattr(self, 'REQUEST', None) | ||
if not isinstance(request, (str, NoneType)): | ||
method=request.get('REQUEST_METHOD', 'GET') | ||
if request.maybe_webdav_client and not method in ('GET', 'POST'): | ||
if (request.maybe_webdav_client and | ||
method not in ('GET', 'POST')): | ||
return NullResource(self, key, request).__of__(self) | ||
raise KeyError, key | ||
|
||
|
@@ -783,7 +785,9 @@ def __nonzero__(self): | |
|
||
security.declareProtected(access_contents_information, 'get') | ||
def get(self, key, default=None): | ||
return self._getOb(key, default) | ||
if key in self: | ||
return self._getOb(key, default) | ||
return default | ||
|
||
security.declareProtected(access_contents_information, 'keys') | ||
def keys(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is pretty inefficient because of how
__contains__
is currently implemented.It would be good to fix
__contains__
so that it doesn't have to do so much work. It currently pulls all ids out and then checks for an occurances in that list: