There's no simple way of constructing URLs to views on different skins

Bug #207640 reported by Jan Wijbrand Kolman
4
Affects Status Importance Assigned to Milestone
grok
Won't Fix
Low
Martijn Faassen
1.0
Won't Fix
Low
Martijn Faassen
1.1
Won't Fix
Undecided
Unassigned

Bug Description

It is currently not possible to easily construct an URL to a view on a different skin/layer. E.g. when you want some view to construct an URL to some REST view.

Changed in grok:
milestone: none → 1.0
Revision history for this message
Jasper Spaans (jspaans) wrote :

There is a hard way, inspired on http://jw.n--tree.net/irclogs/%23grok/%23grok.2008-03-27.log.html :

class ContentRESTLayer(grok.IRESTLayer):
    pass

class ContentRESTProtocol(grok.RESTProtocol):
    grok.layer(ContentRESTLayer)

# A REST handler is not a view; provide a dummy Container that is
# always published using a REST handler. This container can then be
# given its place in the urlspace.
# Note that the context which is probably needed is the __parent__ of
# the context of this container.

class ContentRESTView(grok.Container):
    def render(self):
        return "i don't exist"

from zope.app.publication.interfaces import IBeforeTraverseEvent
from zope.publisher.http import applySkin

@grok.subscribe(ContentRESTView, IBeforeTraverseEvent)
def ContentRESTViewHack(obj, event):
    applySkin(event.request, ContentRESTLayer, grok.IRESTSkinType)

class ContentRESTViewHandler(grok.REST):
    grok.context(ContentRESTView)
    grok.layer(ContentRESTLayer)

    def GET(self):
        context = self.context.__parent__
        return context.somemethod()

Revision history for this message
Martijn Faassen (faassen) wrote :

This looks like a problem that's very hard to solve generally.

Perhaps we want to provide specific solutions for particular cases.

summary: - There's no simple way of constructing URLs to views on different layers
+ There's no simple way of constructing URLs to views on different skins
Changed in grok:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.