Commit b5633ae4 authored by Nikolay Kim's avatar Nikolay Kim

micro optimization

parent 482a309b
......@@ -425,7 +425,7 @@ class ObjectManager(CopyContainer,
# Returns a list of actual subobjects of the current object.
# If 'spec' is specified, returns only objects whose meta_type
# match 'spec'.
return [ self._getOb(id) for id in self.objectIds(spec) ]
return [ getattr(self, id) for id in self.objectIds(spec) ]
security.declareProtected(access_contents_information, 'objectItems')
def objectItems(self, spec=None):
......@@ -763,7 +763,7 @@ class ObjectManager(CopyContainer,
return self.manage_delObjects(ids=[name])
def __getitem__(self, key):
v=self._getOb(key, None)
v=getattr(self, key, None)
if v is not None: return v
if hasattr(self, 'REQUEST'):
request=self.REQUEST
......
......@@ -153,17 +153,16 @@ class Traversable:
path = list(path)
REQUEST = {'TraversalRequestNameStack': path}
#path.reverse()
path_pop = path.pop
if len(path) > 1 and not path[-1]:
if not path[-1]:
# Remove trailing slash
path_pop()
if restricted:
validate = getSecurityManager().validate
if not path[0]:
if path and not path[0]:
# If the path starts with an empty string, go to the root first.
path_pop(0)
obj = self.getPhysicalRoot()
......@@ -189,7 +188,7 @@ class Traversable:
obj = next
continue
bobo_traverse = None
bobo_traverse = getattr(obj, '__bobo_traverse__', None)
try:
if name and name[:1] in '@+' and name != '+' and nsParse(name)[1]:
# Process URI segment parameters.
......@@ -208,7 +207,6 @@ class Traversable:
else:
next = UseTraversalDefault # indicator
try:
bobo_traverse = getattr(obj, '__bobo_traverse__', None)
if bobo_traverse is not None:
next = bobo_traverse(REQUEST, name)
if restricted:
......
......@@ -71,7 +71,7 @@ def boboAwareZopeTraverse(object, path_items, econtext):
while path_items:
name = path_items.pop()
if OFS.interfaces.ITraversable.providedBy(object):
object = object.restrictedTraverse(name)
object = object.unrestrictedTraverse(name, restricted=True)
else:
object = traversePathElement(object, name, path_items,
request=request)
......
......@@ -169,6 +169,9 @@ class HTTPRequest(BaseRequest):
retry_max_count = 3
def __conform__(self, iface):
return iface.__adapt__(self)
def supports_retry(self):
if self.retry_count < self.retry_max_count:
time.sleep(random.uniform(0, 2 ** (self.retry_count)))
......@@ -254,11 +257,11 @@ class HTTPRequest(BaseRequest):
def physicalPathToURL(self, path, relative=0):
""" Convert a physical path into a URL in the current context """
path = self._script + map(quote, self.physicalPathToVirtualPath(path))
path = self._script + [quote(s) for s in self.physicalPathToVirtualPath(path)]
if relative:
path.insert(0, '')
else:
path.insert(0, self['SERVER_URL'])
path.insert(0, self.other['SERVER_URL'])
return '/'.join(path)
def physicalPathFromURL(self, URL):
......@@ -338,7 +341,7 @@ class HTTPRequest(BaseRequest):
self.steps = []
self._steps = []
self._lazies = {}
self._debug = DebugFlags()
self.debug = DebugFlags()
# We don't set up the locale initially but just on first access
self._locale = _marker
......@@ -450,6 +453,9 @@ class HTTPRequest(BaseRequest):
self.cookies = cookies
self.taintedcookies = taintedcookies
def __nonzero__(self):
return True
def processInputs(
self,
# "static" variables that we want to be local for speed
......@@ -1251,7 +1257,7 @@ class HTTPRequest(BaseRequest):
categories. The search order is environment variables,
other variables, form data, and then cookies.
""" #"
"""
other = self.other
if key in other:
return other[key]
......@@ -1379,8 +1385,6 @@ class HTTPRequest(BaseRequest):
if self._locale is _marker:
self.setupLocale()
return self._locale
if key == 'debug':
return self._debug
raise AttributeError, key
return v
......@@ -1517,7 +1521,7 @@ class HTTPRequest(BaseRequest):
base64.decodestring(auth.split()[-1]).split(':', 1)
return name, password
def taintWrapper(self, enabled=False):
def taintWrapper(self, enabled=TAINTING_ENABLED):
return enabled and TaintRequestWrapper(self) or self
def shiftNameToApplication(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment