Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #503 (closed defect: duplicate)

Opened 13 years ago

Last modified 12 years ago

ImportError because of identity decorator

Reported by: jtate@… Owned by: anonymous
Priority: normal Milestone:
Component: Identity Version:
Severity: normal Keywords:


Using today's svn of turbogears, I followed the example at http://trac.turbogears.org/turbogears/wiki/IdentityManagement and created a /secured handler:

    @identity.require( identity.in_group("admin") )
    def secured( self ):
        return dict()

Note the ".templates.secured" html parameter. When visiting the /secured url, I get the login page as expected. When using invalid credentials I'm redirected back to the login page as expected, but when I use valid credentials, I'm presented with the following traceback:

Page handler: <bound method Root.secured of <telepath.controllers.Root object at 0xb752ba2c>>
Traceback (most recent call last):
  File "/home/jtate/devel/turbogears/thirdparty/cherrypy/cherrypy/_cphttptools.py", line 99, in _run
  File "/home/jtate/devel/turbogears/thirdparty/cherrypy/cherrypy/_cphttptools.py", line 247, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in secured
  File "/home/jtate/devel/turbogears/turbogears/controllers.py", line 215, in expose
    func, tg_format, html, fragment, **kw)
  File "/home/jtate/devel/turbogears/turbogears/database.py", line 193, in run_with_transaction
    retval = func(*args, **kw)
  File "/home/jtate/devel/turbogears/turbogears/controllers.py", line 248, in _execute_func
    return _process_output(tg_format, output, html, fragment)
  File "/home/jtate/devel/turbogears/turbogears/controllers.py", line 65, in _process_output
  File "/home/jtate/devel/turbogears/turbogears/view.py", line 60, in render
    return engine.render(info, format, fragment, template)
  File "/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py", line 122, in render
    tclass = self.load_template(template)
  File "/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py", line 94, in load_template
    "%s.kid" % basename)
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 676, in resource_filename
    return get_provider(package_or_requirement).get_resource_filename(
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 119, in get_provider

Now it gets interesting. The following two constructs don't raise the error:

    # Switch the order of the decorators
    @identity.require( identity.in_group("admin") )
    def secured( self ):
        return dict()

    # Use <projectname>.templates.secured
    @identity.require( identity.in_group("admin") )
    def secured( self ):
        return dict()

Change History

comment:1 Changed 13 years ago by Jorge Godoy <jgodoy@…>

Simon Belak has just posted a patch on the mailing list on a thread about the new controller. Try using this patch and see if this solves your problem. your message on the mailing list was preceeded and succeded by messages from me in the said thread.

comment:2 Changed 13 years ago by Jorge Godoy <jgodoy@…>

comment:3 Changed 13 years ago by Jeff Watkins

  • Status changed from new to closed
  • Resolution set to duplicate

Duplicate of #388

Note: See TracTickets for help on using tickets.