Thanks, I'll paste it here:

class ModelsAddRequest: def process_request(self, request): for x in dir(django.models.intranet): klass = django.models.intranet.__dict__[x] if isinstance(klass, meta.ModelBase): klass.request = request
       return None

Yes, (by inspection) that should work. But I am a bit hesitant setting class attribute to a short lived object, especially in a environment where multiple request can hit at the same time. What happen if another request coming just before a Model finish with the previous request?

plisk wrote:

Dody Suria Wijaya wrote:

Is it possible in djanggo to access current request's session variables inside _pre_save or _post_save function? I need to save current login userid into a "last_update_userid" field automatically by simply calling .save()

    Try hack in this thread

http://groups.google.com/group/django-users/browse_thread/thread/31572ab6e8a03d68/81f349eeac9077eb?q=hack+request&rnum=1#81f349eeac9077eb

After you install it as a middleware you can access request in *_save hooks like self.request


Reply via email to