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 #2411 (closed defect: fixed)

Opened 10 years ago

Last modified 9 years ago

@https decorator crashes outside of root

Reported by: seedifferently Owned by:
Priority: normal Milestone: 2.1b2
Component: TurboGears Version: trunk
Severity: normal Keywords:


The pylons.decorators.secure @https decorator throws an error if it is used anywhere other than root.py (i.e., in a "sub-controller"):

AttributeError: 'SecureController' object has no attribute '_py_object'

Steps to reproduce:

  1. Create a brand new quickstart project
  2. Add the decorator import to a sub-controller method (i.e. "some_where" method in controllers/secure.py)
  3. Try to load /secc/some_where/ in a browser

I have tested this in both TG 2.0.3 and 2.1 alpha

Change History

comment:1 Changed 10 years ago by seedifferently

As a workaround, I have been able to get this working by adding:

_py_object = request.environ['pylons.pylons']

Right below the class definition.

comment:2 Changed 10 years ago by mramm

I don't think we tried to make this work....

Your solution is fine, though I might make a SubController? class in lib.py and put that in the subcontroller, and just inherit from that in all your actual subcontrollers.

Other than changing the pylons decorator, I'm not sure what else we can do about this...

comment:3 Changed 9 years ago by jorge.vargas

  • Milestone changed from __unclassified__ to 2.1b1

The problem here seems to be that pylons.decorators.secure wants a "Pylons controller" (see  http://bitbucket.org/bbangert/pylons/src/tip/pylons/decorators/util.py#cl-5) since TG controllers are not pylons controllers I think we shouldn't be setting that attribute. But I may be wrong.

I suggest you open a bug with the pylons team (or get them to comment here) to see if we should be setting that attribute in non-routes controllers.

comment:4 Changed 9 years ago by rick446

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

Fixed in fb9d42127209

comment:5 Changed 9 years ago by rick446

I should mention that this is fixed by adding our own @https decorator in tg.decorators that works with TurboGears decorators, not by fixing pylons.

Note: See TracTickets for help on using tickets.