[controllers] a set_cookie method
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 11 Feb 2009 18:43:32 +0100
changeset 603 18c6c31bbaf4
parent 602 1454282a8b45
child 604 e85042d18b48
[controllers] a set_cookie method
web/views/basecontrollers.py
--- a/web/views/basecontrollers.py	Wed Feb 11 15:59:40 2009 +0100
+++ b/web/views/basecontrollers.py	Wed Feb 11 18:43:32 2009 +0100
@@ -452,7 +452,14 @@
         # link the new entity to the main entity
         rql = 'SET F %(rel)s T WHERE F eid %(eid_to)s, T eid %(eid_from)s' % {'rel' : rel, 'eid_to' : eid_to, 'eid_from' : eid_from}
         return eid_from
-    
+
+    def js_set_cookie(self, cookiename, cookievalue):
+        # XXX we should consider jQuery.Cookie
+        cookiename, cookievalue = str(cookiename), str(cookievalue)
+        cookies = self.req.get_cookie()
+        cookies[cookiename] = cookievalue
+        self.req.set_cookie(cookies, cookiename)
+
 class SendMailController(Controller):
     id = 'sendmail'
     require_groups = ('managers', 'users')