On 6/3/09 10:29 AM, Stephan Altmueller wrote:
> Hi
> It seems that "model_url" does not work correctly with routes that
> do not contain dynamic parts. This worked in 0.7.x but not 0.8 and 0.9.
> Could someone tell if/what I am doing wrong.
> Here is my routes definition in configure.zcml:
>    <route path="buckets"
>           factory=".models.get_buckets_context"
>           view=".views.buckets_view"
>           name="allbuckets" />
> and here is the relevant portion of the of the view code:
> def buckets_view(context, request):
>      context_url = model_url(context, request)
> I expected that "context_url" would be "/buckets" after the call to
> model_url but it's "/".
> Other routes that I am using that have a dynamic part work just fine.
> Any pointer is appreciated.

Hmm.  I can't replicate this.

When I have a "bfg_starter" created project and I change the configure.zcml to 
looks like so:

<configure xmlns="http://namespaces.repoze.org/bfg";>

   <!-- this must be included for the view declarations to work -->
   <include package="repoze.bfg.includes" />



... and I change its views.py to looks like so:

from repoze.bfg.chameleon_zpt import render_template_to_response
from repoze.bfg.view import static
from repoze.bfg.url import model_url

static_view = static('templates/static')

def my_view(context, request):
     print model_url(context, request)
     return render_template_to_response('templates/mytemplate.pt',
                                        request = request,
                                        project = 'routes_stephan')

. and I change models.py to look like so:

class MyModel(object):

root = MyModel()

def get_root(environ):
     return root

class SomeFactory(dict):

When I visit http://localhost:6543/buckets, I see printed to my console 

[chr...@vitaminf routes_stephan]$ ../bin/paster serve routes_stephan.ini
Starting server in PID 73064.
serving on view at

Repoze-dev mailing list

Reply via email to