Hi All,
I'm having a problem testing a view that is dependent on a browserlayer
being installed. When I remove the "layer" directive in ZCML, then the
tests work fine.
The view is registered via ZML as follows:
> <browser:page
> for="*"
> name="calendarfetcher_utils"
> class=".calendarfetcher.CalendarFetcherUtils"
> permission="cmf.ModifyPortalContent"
> layer=".interfaces.ICalendarFetcherLayer"
> allowed_interface=".interfaces.ICalendarFetcherUtils"
> />
As you can see, the browserlayer ICalendarFetcherLayer is required.
I registered the browserlayer in profiles/default/browserlayer.xml:
> <layers>
> <layer
> name="slc.calendarfetcher"
>
> interface="slc.calendarfetcher.browser.interfaces.ICalendarFetcherLayer"
> />
> </layers>
This all works fine and I can access the view in a Plone site, but when
I try to test for this, things go wrong.
In my test code, in the 'setUp' method in the base TestLayer, I register
the browserlayer explicitly, as follows:
> browserlayerutils.register_layer(
> ICalendarFetcherLayer,
> name='slc.calendarfetcher'
> )
In my test method I also test to make sure that the browserlayer is registered
and that my packages is installed:
> qi = getToolByName(self.portal, 'portal_quickinstaller')
> assert(qi.isProductInstalled('slc.calendarfetcher'))
> assert(ICalendarFetcherLayer in
> browserlayer.utils.registered_layers())
When I try to get the view however, via queryMultiAdapter or via traversal, it
fails.
> view = component.queryMultiAdapter(
> (self.portal.calendar, self.portal.calendar.REQUEST),
> name='@@calendarfetcher_utils')
>
> # Only works when browserlayer requirement is removed.
> view =
> self.portal.calendar.restrictedTraverse('@@calendarfetcher_utils')
The queryMultiAdapter returns None and traversal raises an
AttributeError.
If I remove the "layer" directive in the configure.zcml, then the view
is returned via traversal, although the queryMultiAdapter method *still*
returns None, which is weird.
So this tells me that there is likely a problem with the browserlayer
not being present when the view is being queried for.
Does anyone see something that I'm missing? I can't for the life of me
figure out what's amiss.
Thanks very much for any input!
Some more details:
The product I'm developing is in the collective:
https://svn.plone.org/svn/collective/slc.calendarfetcher/trunk/src/slc/calendarfetcher
There is a testing buildout (plone-3.3.x.cfg) included. It has some
specific dependencies, Plone 3.3.5, p4a.plonecalendar 1.1 (branch
checkout), z3c.form 1.9.0 and plone.z3cform <= 0.6.
The versions are pinned in the product's setup.py file.
Regards
JC Brand
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers