skip to navigation
skip to content

cromlech.webob 0.7

Cromlech Web Framework io implementation using WebOb

Downloads ↓

A WebOb implementation of a Cromlech request and response.

Test environnment

Groking :

>>> import grokcore.component
>>> grokcore.component.testing.grok('cromlech.webob')

Importing :

>>> import cromlech.webob
>>> from cromlech.browser import IRequest, IResponse, IWSGIComponent
>>> from zope.interface.verify import verifyClass, verifyObject

Request and Response objects

Based on WebOb ones but providing API:

>>> verifyClass(IRequest, cromlech.webob.request.Request)
>>> verifyObject(IRequest, cromlech.webob.request.Request.blank('/'))

>>> verifyClass(IResponse, cromlech.webob.response.Response)
>>> verifyClass(IWSGIComponent, cromlech.webob.response.Response)

>>> inst = cromlech.webob.response.Response(body='')
>>> verifyObject(IResponse, inst)
>>> verifyObject(IWSGIComponent, inst)


Adapting existing WebOb request or response to meet cromlech API:

>>> import webob
>>> request = webob.Request.blank('/path/to/app')
>>> response = webob.Response()

>>> adapted_request = IRequest(request)
>>> adapted_response = IResponse(response)
>>> adapted_responsive = IWSGIComponent(response)

>>> verifyObject(IRequest, adapted_request)

>>> verifyObject(IResponse, adapted_response)

>>> verifyObject(IWSGIComponent, adapted_responsive)


We provide adapters to retrieve Locale:

>>> from zope.i18n.interfaces.locales import ILocale

>>> locale = ILocale(request)
>>> locale
<zope.i18n.locales.Locale object at 0x...>
>>> locale.getLocaleID()

>>> request.headers['Accept-Language'] = "fr-fr,fr-be,en"
>>> ILocale(request).getLocaleID()

Under the hood locale is choosen thanks to Prefered Language adapter:

>>> from zope.i18n.interfaces import IUserPreferredLanguages
>>> preferredLanguages = IUserPreferredLanguages(request)
>>> preferredLanguages
<cromlech.webob.i18n.RequestPreferredLanguages object at 0x...>
>>> preferredLanguages.getPreferredLanguages()
['fr-fr', 'fr-be', 'en']


0.7 (2016-08-05)

  • Handling virtualhosting by reading the 'HTTP_X_VHM_ROOT' variable from the environ. It's done in the method application_url of the request.

0.6 (2012-05-06)

  • Now using the latest changes made in cromlech.browser. This change is not backward compatible.

0.5 (2012-04-26)

  • Added restriction on the IHTTPResponse adapter, to disallow access to non declated attributes. Tested accordingly.
  • Added an IWSGIResponsive adapter for IWebObResponse.
  • cromlech.webob.response.Response now implements IWSGIResponsive.

0.4 (2012-01-24)

  • Added redirection handling as a multiadapter, to match the changes made in cromlech.dawnlight. The multiadapter's module must be grokked by hand, it won't be done for you if you include this package.

0.3 (2012-01-11)

  • Made the necessary changes in the implementation to the latest cromlech packages working. This includes changing moving old references to the new cromlech.browser HTTP ones.
  • Adapted the i18n work to the new WebOb.

0.2a1 (2011-07-20)

  • We now make sure our 'form' is a classic dict and not a MultiDict.


  • Initial release
  • i18n adapted from zope.publisher
File Type Py Version Uploaded on Size # downloads
cromlech.webob-0.7.tar.gz (md5) Source 2016-08-05 6KB 0