Solving my own problem... This wasn't nearly as hard as I thought,
here's the solution that worked for me:
urls.py
#####
from datetime import datetime, timedelta
from django.conf.urls.defaults import *
from django.contrib.comments.views import comments
...others...
def remember_wrapper(fn):
"Set a cookie for commenters who want their personal info to be
remembered."
def wrapper(request,*args,**kwargs):
resp = fn(request,*args,**kwargs)
if resp.status_code == 302: # 302 must mean successful
post
if request.POST.get("remember",False):
cookie_val = "%s,%s,%s" % (request.POST.get
("name",''),request.POST.get("email",''),request.POST.get("url",''))
exp = datetime.now() + timedelta(days=30)
resp.set_cookie('mysite_comment',cookie_val,expires=exp.strftime
('%a, %d %b %Y %H:%M:%S'))
else:
resp.delete_cookie('mysite_comment')
return resp
return wrapper
urlpatterns = patterns("",
...many...
(r'^comments/post/$',remember_wrapper(comments.post_comment)),
(r'^comments/', include('django.contrib.comments.urls')),
...and more...
)
The views that display comment forms check for this cookie, and use
the information to populate the form. I suppose that could be done as
a context processor.
Hope someone finds that useful,
Eric
On Jan 4, 12:03 pm, Eric Abrahamsen <[email protected]> wrote:
> Hi there,
>
> I'm adding a "remember me" checkbox tocommentforms, so that regular
> commenters can avoid having to enter their personal information, if
> they want. I was originally thinking of making this a function
> attached to the comment_was_posted signal, but it will have to be
> implemented using cookies, which need to be set on the outgoing
> response, which isn't available in signal handlers...
>
> I'm wondering if anyone else has made a functionality like this using
> thecommentcontrib app, and how they went about doing it. There
> doesn't seem to be any point in the process where I could get hold of
> the response.
>
> Thanks!
> Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---