Hi devs, I ran into an issue the other day that got me thinking about the 0.11 Context object.
The issue was to figure out how to render arbitrary wiki markup without a request object - which was no problem with 0.10 wiki_to_... () methods. Now with the context and the new security branch, calling the formatter (via format_to_html()) it will somewhere deep down say that there is no req.perm to use when rendering links. Essentially I am trying something like this: m = format_to_html(Context(env, None), 'Test: [wiki:WikiStart]') This particular problem is not yet solved (input welcome :-), but the important thing here is that it got me thinking about the context object which is becoming very central in much of the source. I like the idea of the context object. It has the potential to simplify my interface to the data and logic. However, too often the context object is just used to package env and req, so that at the receiving end it is only used as: env = context.env req = context.req ... and the code goes about it's business looking up entities in env and req as it sees fit - and mostly as before, with the increasing need for accessing req.perm introduced by new security. In my mind, the context object should be the core entity for contextual information. From the example above, one should not ask for req.perm but instead context.perm. Only rarely (and with good reasons) should model or utility code really need a request object to work with a resource. That should be kept in the front-end code. Permissions and username are obvious additions to the context I think - having the context be some function of the project, the resource, and in the context of a given user and security policies. It would be ideal if the context initialisation could override default rules by passing further keyword args, like: c = Context(env, req, authname='simon') Then, regardless of actual values in req I could pass this context around, and know that everything would work in the context of that user. Another example would be to pass a custom href and abs_href to override the defaults fetched usually attached to req and/or env. Or, as my problem above; if the req object doesn't exist, the perm logic is automatically fetched elsewhere and added to the context. A context object with context.authname, context.perm and context.href would eliminate most uses of req in back-end code. :::simon http://www.coderesort.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Trac Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-dev?hl=en -~----------~----~----~----~------~----~------~--~---
