[Checkins]
SVN: Sandbox/philikon/five.publication/trunk/five/publication/
Split request class out to separate module.
Philipp von Weitershausen
philikon at philikon.de
Fri Aug 3 14:19:37 EDT 2007
Log message for revision 78558:
Split request class out to separate module.
Changed:
U Sandbox/philikon/five.publication/trunk/five/publication/configure.zcml
U Sandbox/philikon/five.publication/trunk/five/publication/publication.py
A Sandbox/philikon/five.publication/trunk/five/publication/request.py
-=-
Modified: Sandbox/philikon/five.publication/trunk/five/publication/configure.zcml
===================================================================
--- Sandbox/philikon/five.publication/trunk/five/publication/configure.zcml 2007-08-03 18:07:22 UTC (rev 78557)
+++ Sandbox/philikon/five.publication/trunk/five/publication/configure.zcml 2007-08-03 18:19:36 UTC (rev 78558)
@@ -10,6 +10,6 @@
priority="0"
/>
- <adapter factory=".publication.BrowserPublisher" />
+ <adapter factory=".publication.DefaultBrowserPublisher" />
</configure>
Modified: Sandbox/philikon/five.publication/trunk/five/publication/publication.py
===================================================================
--- Sandbox/philikon/five.publication/trunk/five/publication/publication.py 2007-08-03 18:07:22 UTC (rev 78557)
+++ Sandbox/philikon/five.publication/trunk/five/publication/publication.py 2007-08-03 18:19:36 UTC (rev 78558)
@@ -1,9 +1,7 @@
-import re
import transaction
import zope.interface
import zope.component
import zope.event
-import zope.publisher.browser
from zope.component import queryMultiAdapter
from zope.security.management import newInteraction, endInteraction
@@ -23,80 +21,8 @@
from ZPublisher.mapply import mapply
from ZPublisher.BaseRequest import RequestContainer
-marker = object()
-# lifted from ZPublisher.HTTPRequest
-URLmatch = re.compile('URL(PATH)?([0-9]+)$').match
-BASEmatch = re.compile('BASE(PATH)?([0-9]+)$').match
+from five.publication.request import BrowserRequest
-class BrowserRequest(zope.publisher.browser.BrowserRequest):
-
- def __init__(self, body_instream, environ, response=None):
- self.other = {}
- super(BrowserRequest, self).__init__(body_instream, environ, response)
- self.__setupLegacy()
-
- def __setupLegacy(self):
- self.other.update({
- 'REQUEST': self,
- 'PARENTS': [], # TODO check if we remember all parents yet
- 'BODYFILE': self.bodyStream,
- })
-
- #XXX
- self.maybe_webdav_client = False
-
- def get(self, key, default=None):
- if key in self.other:
- return self.other[key]
-
- if key == 'RESPONSE':
- return self.response
-
- # support URLn, URLPATHn
- if key.startswith('URL'):
- if key == 'URL':
- return self.getURL()
- match = URLmatch(key)
- if match is not None:
- pathonly, n = match.groups()
- # XXX is this correct?
- return self.getURL(int(n), pathonly)
-
- # support BASEn, BASEPATHn
- if key.startswith('BASE'):
- # XXX just 'BASE'???
- match = BASEmatch(key)
- if match is not None:
- pathonly, n = match.groups()
- # XXX I have no clue what to return here
- return self.getURL(int(n), pathonly)
-
- # support BODY
- #XXX
-
- return super(BrowserRequest, self).get(key, default)
-
- def keys(self):
- 'See Interface.Common.Mapping.IEnumerableMapping'
- keys = set(self._environ.keys() + self._cookies.keys()
- + self.form.keys() + self.other.keys())
- # TODO URLn, URLPATHn, BASEn, BASEPATHn
- keys.update(['URL', 'RESPONSE'])
- return list(keys)
-
- # BBB discouraged methods:
-
- def __setitem__(self, key, value):
- self.other[key] = value
-
- set = __setitem__
-
- def __getattr__(self, key, default=marker):
- value = self.get(key, default)
- if value is marker:
- raise AttributeError(key)
- return value
-
class BrowserPublication(object):
zope.interface.implements(IPublication)
@@ -207,7 +133,7 @@
def __call__(self):
return BrowserRequest, BrowserPublication
-class BrowserPublisher(ZPublisher.BaseRequest.DefaultPublishTraverse):
+class DefaultBrowserPublisher(ZPublisher.BaseRequest.DefaultPublishTraverse):
zope.component.adapts(None, IBrowserRequest)
zope.interface.implements(IBrowserPublisher)
Added: Sandbox/philikon/five.publication/trunk/five/publication/request.py
===================================================================
--- Sandbox/philikon/five.publication/trunk/five/publication/request.py (rev 0)
+++ Sandbox/philikon/five.publication/trunk/five/publication/request.py 2007-08-03 18:19:36 UTC (rev 78558)
@@ -0,0 +1,76 @@
+import re
+import zope.publisher.browser
+
+marker = object()
+# lifted from ZPublisher.HTTPRequest
+URLmatch = re.compile('URL(PATH)?([0-9]+)$').match
+BASEmatch = re.compile('BASE(PATH)?([0-9]+)$').match
+
+class BrowserRequest(zope.publisher.browser.BrowserRequest):
+
+ def __init__(self, body_instream, environ, response=None):
+ self.other = {}
+ super(BrowserRequest, self).__init__(body_instream, environ, response)
+ self.__setupLegacy()
+
+ def __setupLegacy(self):
+ self.other.update({
+ 'REQUEST': self,
+ 'PARENTS': [], # TODO check if we remember all parents yet
+ 'BODYFILE': self.bodyStream,
+ })
+
+ #XXX
+ self.maybe_webdav_client = False
+
+ def get(self, key, default=None):
+ if key in self.other:
+ return self.other[key]
+
+ if key == 'RESPONSE':
+ return self.response
+
+ # support URLn, URLPATHn
+ if key.startswith('URL'):
+ if key == 'URL':
+ return self.getURL()
+ match = URLmatch(key)
+ if match is not None:
+ pathonly, n = match.groups()
+ # XXX is this correct?
+ return self.getURL(int(n), pathonly)
+
+ # support BASEn, BASEPATHn
+ if key.startswith('BASE'):
+ # XXX just 'BASE'???
+ match = BASEmatch(key)
+ if match is not None:
+ pathonly, n = match.groups()
+ # XXX I have no clue what to return here
+ return self.getURL(int(n), pathonly)
+
+ # support BODY
+ #XXX
+
+ return super(BrowserRequest, self).get(key, default)
+
+ def keys(self):
+ 'See Interface.Common.Mapping.IEnumerableMapping'
+ keys = set(self._environ.keys() + self._cookies.keys()
+ + self.form.keys() + self.other.keys())
+ # TODO URLn, URLPATHn, BASEn, BASEPATHn
+ keys.update(['URL', 'RESPONSE'])
+ return list(keys)
+
+ # BBB discouraged methods:
+
+ def __setitem__(self, key, value):
+ self.other[key] = value
+
+ set = __setitem__
+
+ def __getattr__(self, key, default=marker):
+ value = self.get(key, default)
+ if value is marker:
+ raise AttributeError(key)
+ return value
Property changes on: Sandbox/philikon/five.publication/trunk/five/publication/request.py
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list