|
List Info
Thread: Class variables in mod_python
|
|
| Class variables in mod_python |

|
2006-07-30 17:36:09 |
Hi.
I've built a password reset mechanism for my application
using class
variables to store random passwords which are later used to
authorize
password resets.
Here's what I'm using:
# Speichert Passwortanfragen und gibt sie bei Bedarf zurück
class PasswordRequest:
requests = {}
def newRequest(self, username, key):
self.requests[username] = key
def getRequest (self, username):
if self.requests.has_key(username):
return self.requests[username]
return None
def removeRequest(self, username):
if self.requests.has_key(username):
del self.requests[username]
This works fine in the development server. Under mod_python,
though, it
appears that these class variables don't work (getRequest
doesn't
return what I've previously put in via newRequest). Is
there a
difference wrt class variables between mod_python and the
development
server?
I'd assume the problem was due to the fact that mod_python
spawns new
processes for each request, right?
Is there a workable solution for using class variables with
mod_python?
I'd hate to store this temporary information (removed once
the user
successfully changed his password) in the DB.
Or is there something else scwewy awound here?
Daniel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Class variables in mod_python |

|
2006-07-30 18:03:34 |
On Jul 30, 2006, at 10:36 AM, daniel.tietze gmail.com
wrote:
>
> ...
> I'd assume the problem was due to the fact that
mod_python spawns new
> processes for each request, right?
>
> Is there a workable solution for using class variables
with
> mod_python?
> I'd hate to store this temporary information (removed
once the user
> successfully changed his password) in the DB.
>
> Or is there something else scwewy awound here?
Why not use sessions?
Don
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Class variables in mod_python |

|
2006-07-30 18:17:10 |
On 7/30/06, daniel.tietze gmail.com
<daniel.tietze gmail.com> wrote:
> This works fine in the development server. Under
mod_python, though, it
> appears that these class variables don't work
(getRequest doesn't
> return what I've previously put in via newRequest). Is
there a
> difference wrt class variables between mod_python and
the development
> server?
>
> I'd assume the problem was due to the fact that
mod_python spawns new
> processes for each request, right?
Yeah, that's exactly it. You shouldn't really count on any
sort of
global variables in mod_python, because there's no
guarantee you'll
get the same Python interpreter for one request that you got
for a
previous request.
> Is there a workable solution for using class variables
with mod_python?
> I'd hate to store this temporary information (removed
once the user
> successfully changed his password) in the DB.
You could use the cache framework to store stuff in there
temporarily.
Alternatively, I don't think it's a huge problem to store
that in the
database.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Class variables in mod_python |

|
2006-07-30 18:37:09 |
Adrian Holovaty wrote:
[...]
> You could use the cache framework to store stuff in
there temporarily.
> Alternatively, I don't think it's a huge problem to
store that in the
> database.
Thanks for your quick response! Good to know that at least I
was on the
right track as to what my problem was.
I changed it to use a database table. I just felt that this
was nothing
that *needed* to be persistent. Oh, well. No big deal.
Cheers,
Daniel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
[1-4]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|