Skip to content

Commit

Permalink
Fixed application_url() calls to use keyword arguments where the API
Browse files Browse the repository at this point in the history
defines keyword arguments.
  • Loading branch information
janwijbrand committed Apr 3, 2013
1 parent cd08bb4 commit c648615
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/grok/ftests/url/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
>>> browser.open('http://localhost/cave')
>>> browser.contents
'http://localhost/cave'
Asking for the application_url on the caveman returns the URL to the cave as
well::
Expand All @@ -28,22 +28,33 @@
>>> browser.contents
'http://localhost/cave/second'
URLs can be computed for skins too::
>>> browser.open('http://localhost/cave/caveman/third')
>>> browser.contents
'http://localhost/++skin++mammothskin/cave/third'
>>> browser.open('http://localhost/cave/caveman/fourth')
>>> browser.contents
'http://localhost/++skin++mammothskin/cave/fourth?key=value'
application_url also works with empty containers::
>>> from grok.ftests.url.application import Corridors
>>> cave['corridors'] = Corridors()
>>> browser.open('http://localhost/cave/corridors')
>>> browser.contents
'http://localhost/cave'
"""
import zope.interface
import grok
from zope.publisher.interfaces.browser import IDefaultBrowserLayer

class IMarker(zope.interface.Interface):
pass


class Index(grok.View):
grok.context(IMarker)

Expand All @@ -55,7 +66,7 @@ class Second(grok.View):

def render(self):
return self.application_url('second')

class Cave(grok.Application, grok.Container):
grok.implements(IMarker)

Expand All @@ -64,3 +75,19 @@ class CaveMan(grok.Model):

class Corridors(grok.Container):
grok.implements(IMarker)

class IMammothSkin(IDefaultBrowserLayer):
grok.skin('mammothskin')

class Third(grok.View):
grok.context(IMarker)

def render(self):
return self.application_url('third', skin=IMammothSkin)

class Fourth(grok.View):
grok.context(IMarker)

def render(self):
return self.application_url(
'fourth', skin=IMammothSkin, data={'key': 'value'})

0 comments on commit c648615

Please sign in to comment.