quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Dumpleton <grah...@dscpl.com.au>
Subject get_session(), req.session, req.form and MODPYTHON-38
Date Mon, 13 Mar 2006 08:50:32 GMT
That get_session() was being added at the C code level was also one of
the things that worried me about this change. Thus in part why my
suggestion for an alternate approach didn't touch the request object
at all.

While we are talking about this issue of additions to the request 
object,
the documentation says:

   The request object is a Python mapping to the Apache request_rec 
structure.
   When a handler is invoked, it is always passed a single argument - 
the request object.

   You can dynamically assign attributes to it as a way to communicate 
between handlers.

The bit I want to highlight is the last line about handlers dynamically
assigning attributes to the request object.

Being able to do this is quite useful and is already used within
mod_python.publisher. Specifically, it assigns the instance of the
FieldStorage object to req.form. This can then be accessed by the
published function.

As I describe in:

   https://issues.apache.org/jira/browse/MODPYTHON-38

I want to formalise a couple of current conventions regarding attributes
being assigned to the request object by handlers. I have mentioned 
req.form.
The other I want to formalise is req.session.

Thus I want a documented convention that if a handler is going to use
util.FieldStorage, that it should before doing so, first check whether
an existing instance resides as req.form and use that instead.

Similarly, if a handler is going to create a Session object, that it
look for an existing instance as req.session and again use that instead.

Both mod_python.psp and mod_python.publisher would be modified to follow
the convention, which would then avoid the problems which sometimes
come up when people try and use the two together. Ie., both trying to
parse form arguments, or both trying to create session objects and
locking each other out.

Is there support for doing this? If so I'll up it on my priority list.

Note, this isn't addressing some of what the get_session() changes
were intended to address, specifically issues of internal redirects,
but I think it is a good start to at least address this, with any
final solution building around this convention.

Graham

On 13/03/2006, at 2:39 PM, Gregory (Grisha) Trubetskoy wrote:

>
> I'm -1 on get_session() too. The request object is supposed to be a 
> representation of Apache's request, and get_session() just does not 
> belong there.
>
> Grisha
>
> On Sun, 12 Mar 2006, Jim Gallacher wrote:
>
>> I handn't really intended to start working on an implementation. I 
>> just don't like seeing all those issues in JIRA marked as unassigned. 
>> :) Since I created it I figured I should take some responsibility for 
>> it. Plus, it's a gentle reminder when I list my assigned issues - 
>> resolve it one way or another.
>>
>> I still think we need some sort of solution to the problem of people 
>> trying to create 2 session instances in the same request, but I agree 
>> that the original concept of req.get_session() was not quite right.
>>
>> Jim
>>
>> Graham Dumpleton wrote:
>>> I would rather we not go ahead with adding req.get_session() at
>>> this time. At least not how it was envisaged to be done previously.
>>> I'll come back with a bit of analysis after I review where we were
>>> up to previously.
>>> Graham
>>> On 12/03/2006, at 8:47 AM, Jim Gallacher (JIRA) wrote:
>>>>      [ http://issues.apache.org/jira/browse/MODPYTHON-59?page=all ]
>>>> Jim Gallacher reassigned MODPYTHON-59:
>>>> --------------------------------------
>>>>     Assign To: Jim Gallacher
>>>>> Add get_session() method to request object
>>>>> ------------------------------------------
>>>>>          Key: MODPYTHON-59
>>>>>          URL: http://issues.apache.org/jira/browse/MODPYTHON-59
>>>>>      Project: mod_python
>>>>>         Type: New Feature
>>>>>   Components: session
>>>>>     Versions: 3.1.4, 3.1.3, 3.2.7
>>>>>  Environment: All
>>>>>     Reporter: Jim Gallacher
>>>>>     Assignee: Jim Gallacher
>>>>>      Fix For: 3.3
>>>>>  Attachments: Session.py.diff.txt
>>>>> Users will get session instances by calling req.get_session(). If 
>>>>> a session already exists it will be returned, otherwise a new 
>>>>> session instance will be created. Session configuration will be 
>>>>> handled using apache directives rather than within their code.
>>>>> Using this scheme means only one session instance will be created 
>>>>> per request, which will eliminate the deadlock problems many 
>>>>> people experience. Also, using this scheme makes it possible for 
>>>>> sessions to be properly handled within psp pages and across 
>>>>> req.internal_redirect() calls.
>>>>> Code will be commited to svn shortly.
>>>> -- 
>>>> This message is automatically generated by JIRA.
>>>> -
>>>> If you think it was sent incorrectly contact one of the 
>>>> administrators:
>>>>    http://issues.apache.org/jira/secure/Administrators.jspa
>>>> -
>>>> For more information on JIRA, see:
>>>>    http://www.atlassian.com/software/jira
>>


Mime
View raw message