I’m developing a plone4 site on which every user have a sortable inventory of items. The ATFolder’s folder_content view is ideal for this. The only problem is that instead of an URL like this:
/site/user/inventory
or this
/site/inventory/user
the url should be:
/site/inventory
I’ve thought in several solution, but each one have its own doubts.
- Make the inventory content dynamic, depending on the authenticated user. I don’t even know if this is possible on plone.
- Somehow to cheat the transversal mechanism, so /site/inventory render /site/inventory/user.
- Change the context before rendering the view. Again, don’t know if possible.
- Make inventory a subclass of ATCTContent, store the inventory data as annotation on the user and develop the ordering code all by myself. This is the option I’m trying to avoid.
What would you do?
Thanks.
Well, it’ll be easy to define a
inventoryview that then uses the Authenticated User to render it’s contents, which could be a simple delegation to an ordered folder that is stored at /site/users/user/folder.The one thing that you have to remember is that user authentication happens after traversal. This means that when a view is instantiated (it’s
__init__method is called) there is no user determined yet because that happens during traversal. Look up your user in the view__call__or from it’s template instead.