summaryrefslogtreecommitdiff
path: root/repoze
diff options
context:
space:
mode:
authorMalthe Borch <mborch@gmail.com>2008-12-04 21:49:51 +0000
committerMalthe Borch <mborch@gmail.com>2008-12-04 21:49:51 +0000
commit2eca00a3dbbcdb2bd767840d0cebde5d9e172340 (patch)
tree094df29482d2f120432dc2ee78753d9ef16fac18 /repoze
parentbab58c68284783e066795614c8ae4782af6edc4e (diff)
downloadpyramid-2eca00a3dbbcdb2bd767840d0cebde5d9e172340.tar.gz
pyramid-2eca00a3dbbcdb2bd767840d0cebde5d9e172340.tar.bz2
pyramid-2eca00a3dbbcdb2bd767840d0cebde5d9e172340.zip
View component registration is now able to use the 'adaptation annotation' scheme (see zope.component.adaptedBy); the change-log entry has detailed information.
Diffstat (limited to 'repoze')
-rw-r--r--repoze/bfg/zcml.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py
index 960be33bc..aba5847d2 100644
--- a/repoze/bfg/zcml.py
+++ b/repoze/bfg/zcml.py
@@ -2,10 +2,12 @@ import cPickle
import os
from os.path import realpath
import time
+import types
from zope.configuration import xmlconfig
from zope.component import getSiteManager
+from zope.component import adaptedBy
import zope.configuration.config
from zope.component.interface import provideInterface
@@ -36,7 +38,7 @@ def view(_context,
for_=None,
view=None,
name="",
- request_type=IRequest,
+ request_type=None,
cacheable=True,
):
@@ -50,6 +52,26 @@ def view(_context,
args = ('', for_)
)
+ # views may be either functions or class instances
+ if isinstance(view, types.FunctionType):
+ adapted_by = adaptedBy(view)
+ else:
+ adapted_by = adaptedBy(type(view))
+
+ if adapted_by is not None:
+ try:
+ if for_ is None:
+ for_, _ = adapted_by
+ if request_type is None:
+ _, request_type = adapted_by
+ except ValueError:
+ # the component adaptation annotation does not conform to
+ # the view specification; we ignore it.
+ pass
+
+ if request_type is None:
+ request_type = IRequest
+
if permission:
pfactory = ViewPermissionFactory(permission)
_context.action(
@@ -150,7 +172,7 @@ def zcml_configure(name, package, load=cPickle.load):
return file_configure(name, package)
mtime = os.stat(realpath(file)).st_mtime
-
+
if mtime >= ptime:
return file_configure(name, package)