[Checkins] SVN: hurry.zoperesource/trunk/ Ignore need() if no request can be found. Prepare for release.
Martijn Faassen
faassen at infrae.com
Fri Dec 5 14:07:12 EST 2008
Log message for revision 93675:
Ignore need() if no request can be found. Prepare for release.
Changed:
U hurry.zoperesource/trunk/CHANGES.txt
U hurry.zoperesource/trunk/src/hurry/zoperesource/zopesupport.py
-=-
Modified: hurry.zoperesource/trunk/CHANGES.txt
===================================================================
--- hurry.zoperesource/trunk/CHANGES.txt 2008-12-05 18:53:11 UTC (rev 93674)
+++ hurry.zoperesource/trunk/CHANGES.txt 2008-12-05 19:07:12 UTC (rev 93675)
@@ -1,10 +1,16 @@
CHANGES
*******
-0.3 (unreleased)
+0.3 (2008-12-05)
================
-* ...
+* ``resource.need()`` needed a request object set up in order to
+ function. This is rather annoying in tests, which often don't have
+ a request object set up. We now instead return a dummy
+ ``NeededResources`` object in such cases (which will then be thrown
+ away). As a result, it's always safe to call ``resource.need()``
+ during tests, though if no request can be found it will have no
+ effect.
0.2 (2008-10-13)
================
Modified: hurry.zoperesource/trunk/src/hurry/zoperesource/zopesupport.py
===================================================================
--- hurry.zoperesource/trunk/src/hurry/zoperesource/zopesupport.py 2008-12-05 18:53:11 UTC (rev 93674)
+++ hurry.zoperesource/trunk/src/hurry/zoperesource/zopesupport.py 2008-12-05 19:07:12 UTC (rev 93675)
@@ -18,7 +18,16 @@
grok.provides(ICurrentNeededInclusions)
def __call__(self):
- request = getRequest()
+ try:
+ request = getRequest()
+ except NoRequestError:
+ # in some situations no request is set up
+ # to let 'need()' happen freely in places where
+ # no request is available (such as tests) we will
+ # silently assume that this is all right and return
+ # an empty NeededInclusions
+ return NeededInclusions()
+
if not hasattr(request, 'hurry_resource_needed'):
request.hurry_resource_needed = NeededInclusions()
return request.hurry_resource_needed
More information about the Checkins
mailing list