Ticket #2411 (closed defect: fixed)
@https decorator crashes outside of root
| Reported by: | seedifferently | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.1b2 |
| Component: | TurboGears | Version: | trunk |
| Severity: | normal | Keywords: | |
| Cc: |
Description
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:
- Create a brand new quickstart project
- Add the decorator import to a sub-controller method (i.e. "some_where" method in controllers/secure.py)
- 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:2 Changed 2 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 2 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 2 years ago by rick446
- Status changed from new to closed
- Resolution set to fixed
Fixed in fb9d42127209
comment:5 Changed 2 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.
As a workaround, I have been able to get this working by adding:
Right below the class definition.