durusmail: quixote-users: Re: Request contexts
Request contexts
2003-12-11
Re: Request contexts
2003-12-11
2003-12-11
2003-12-12
2003-12-12
2003-12-13
2003-12-13
2003-12-16
2003-12-16
2003-12-16
2003-12-16
2003-12-15
Re: Request contexts
2003-12-16
2003-12-16
2003-12-24
2003-12-30
2003-12-31
Re: Request contexts
Oscar Rambla
2003-12-24
On Tuesday 16 December 2003 16:42, Oscar Rambla wrote:
> On Monday 15 December 2003 19:13, Graham Fawcett wrote:
> > Personally, I like the idea of passing the applications/packages/api's to
> > the Publisher. A drawback of your approach is that it requires a
> > SessionPublisher in order to work, and thus it is a bit less general.
>
> It's begining to like me, too.
> I think,  Publisher context is convenient.
>
> In my case, this could help bring up user session and other off session
> functions.
>
> Later, session and application (and others) while traversing could
> update/upgrade request.context.
>
> Your comments have made improve my understanding. (Hope!)
>

Continue.. (Are you still there?)

I've been working a bit (slowly) on your proposal.

One thing worries me about it is that someone (me, for example) could be
tempted to use request.context for storing things he didn't expect to survive
publisher's live long.

Currently , i'm woking on this variant from your patch and Dave Kuhlman's
example. (In fact, a SessionPublisher version of this). Don't pretend it to
be better than yours, only to ilustrate my point of view.

class ContextPublisher( Publisher ):

    def __init__ (self, root_namespace,  context_class, config=None):
        Publisher.__init__(self, root_namespace, config)

        self._context_class = context_class

    def set_context(self, context_class):
        self._context_class = context_class

    def start_request(self, request):
        # start_request seems to be made for this kind of things
        request.context = self._context_class()

        # nobody knows if sometime it won't be empty ;-)
        Publisher.start_request(self, request)

# class ContextPublisher

Advantages:
.Make context attributes available application wide. ( Your point).
.Keeps integrity of initial context.

Known limitations:
.Involves subclassing Publisher. (What you try to avoid).
.Forces Context to be a class with an empty argument list constructor.

Objections, suggestions? please.


Oscar Rambla
CODI

Merry Christmas to all quixotists.



reply