My colleague Huub figured it out, I'll try to explain it. When the ++UserRating++ traverser lookup is done, another adapter lookup for traversal is applied to the view, which ends up with Products.Five.browser.metaconfigure.ViewMixinForTemplates's publishTraversal. We added our own publishTraverse method to the view to use from ZPublisher.BaseRequest.DefaultPublishTraverse instead.
A new problem occurred then: After rating, an IObjectRatedEvent event is fired. If this inherits from IObjectModified, you'll get permission errors. We subclassed it from zope.component.interfaces.IObjectEvent instead. The complete changeset is here: http://dev.plone.org/collective/changeset/111030/contentratings/trunk Kees Kees Hink wrote: > The problem isn't with Anonymous/Authenticated, but with the "rate" method on > the ++UserRating++ view. This is inaccessible for both types of users. > (However, with KSS enabled for Anonymous, rating still doesn't work, while it > does work for Authenticated.) > > Going to http://127.0.0.1:8080/Plone/front-page/++UserRating++/rate?value=2 > yields an error: > NotFound: Object: <Products.Five.metaclass.SimpleViewClass from > /home/kees/myproject/src/contentratings/contentratings/browser/stars.pt object > at 0x8e594d0>, name: 'rate' > > The error log shows it's > Products.Five.browser.metaconfigure.ViewMixinForTemplates, which fails in > publishTraverse: > def publishTraverse(self, request, name): > if name == 'index.html': > return self.index > raise NotFound(self, name, request) > "name" here is 'rate', so that explains it. > > ++UserRating++ is defined in contentratings/browser/configure.zcml: > <zope:view > name="UserRating" > type="zope.interface.Interface" > provides="zope.traversing.interfaces.ITraversable" > for="*" > factory=".traverser.user_rating" > /> > > I'm don't know why viewing this works, and viewing an attribute doesn't. I've > tried adding > allowed_attributes="rate remove_rating" > permission="zope.Public" > , but that doesn't help. > > Any suggestions for further investigation? > > Kees Hink wrote: >> I fixed some tests in contentratings/trunk, so they pass in Plone 4. I also >> included the patch (mentioned earlier in this thread) to subclass views from >> 'Acquisition.Explicit'. Still works on Plone 3 as well. >> >> On i go... >> >> Kees Hink wrote: >>> The mentioned test passes when testing via ./bin/test -s contentratings. So >>> the >>> failing was probably due to missing zcml setup. >>> >>> Raphael Ritz wrote: >>>> Kees Hink wrote: >>>>> While browsing the documentation of contentrating and executing the >>>>> python code >>>>> in a ./bin/zopepy shell, i ran into this (README.txt:93): >>>>> >>>>>>>> adapted = IUserRating(content) >>>>> Traceback (most recent call last): >>>>> File "<console>", line 1, in <module> >>>>> TypeError: ('Could not adapt', <zope.container.sample.SampleContainer >>>>> object at >>>>> 0x2ad8910>, <InterfaceClass contentratings.interfaces.IUserRating>) >>>>> >>>> Wild guess: The adapter to IUserRating is registered for >>>> an interface (or interfaces) that are no longer provided >>>> by some or all relevant content items. >>>> If that's the case, one would either have to mark those >>>> content types accordingly or adjust/extend the adapter >>>> registration. >>>> >>>> No clue whether that points you in the right direction though, >>>> >>>> Raphael >>>> >>>> >>>> >>>>> Could this be the cause of the problem, or is this due to some zcml >>>>> setup which >>>>> is not taken into account when running the code from the zopepy shell? >>>>> >>>>> I also tried testing using zc.recipe.testrunner, but i don't have this >>>>> working yet. >>>>> >>>>> Kees >>>>> _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
