Page MenuHomec4science

youralerts.py.wml
No OneTemporary

File Metadata

Created
Sun, Jun 30, 15:30

youralerts.py.wml

## $Id$
## PERSONAL FEATURE - YOUR ALERTS
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##read config variables
#include "config.wml"
#include "configbis.wml"
<protect>## $Id$ </protect>
<protect>## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.</protect>
"""PERSONAL FEATURES - YOUR ALERTS"""
__lastupdated__ = """<: print `date +"%d %b %Y %H:%M:%S %Z"`; :>"""
## fill config variables:
pylibdir = "<LIBDIR>/python"
import sys
import time
import zlib
import urllib
import time
sys.path.append('%s' % pylibdir)
from cdsware.config import weburl
from cdsware.webpage import page
from cdsware import webalert
from cdsware.webuser import getUid
from mod_python import apache
def relative_redirect( req, relative_url, **args ):
tmp = []
for param in args.keys():
#ToDo: url encoding of the params
tmp.append( "%s=%s"%( param, args[param] ) )
req.err_headers_out.add("Location", "%s/%s?%s" % (weburl, relative_url, "&".join( tmp ) ))
raise apache.SERVER_RETURN, apache.HTTP_MOVED_PERMANENTLY
### CALLABLE INTERFACE
def display(req, p="n"):
uid = getUid(req)
return page(title="Display searches",
body=webalert.perform_display(p,uid),
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
description="CDS Personalize, Display searches",
keywords="CDS, personalize",
uid=uid,
lastupdated=__lastupdated__)
def input(req, idq, name="", freq="week", notif="y", idb=0, error_msg=""):
uid = getUid(req)
html = webalert.perform_input_alert("add", idq, name, freq, notif, idb,uid)
if error_msg != "":
html ="""<div class="quicknote">%s</div><br>%s"""%(error_msg, html)
return page(title="Set a new alert",
body=html,
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
description="CDS Personalize, Set a new alert",
keywords="CDS, personalize",
uid=uid,
lastupdated=__lastupdated__)
def modify(req, idq, old_idb, name="", freq="week", notif="y", idb=0, error_msg=""):
uid = getUid(req)
html = webalert.perform_input_alert("update", idq, name, freq, notif, idb,uid, old_idb)
if error_msg != "":
html ="""<div class="quicknote">%s</div><br>%s"""%(error_msg, html)
return page(title="Modify alert settings",
body=html,
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
description="CDS Personalize, Modify alert settings",
keywords="CDS, personalize",
uid=uid,
lastupdated=__lastupdated__)
def list(req):
uid = getUid(req)
return page(title="Display alerts",
body=webalert.perform_list_alerts(uid),
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
description="CDS Personalize, Display alerts",
keywords="CDS, personalize",
uid=uid,
lastupdated=__lastupdated__)
def add(req, name, freq, notif, idb, bname, idq):
uid = getUid(req)
try:
html=webalert.perform_add_alert(name, freq, notif, idb, bname, idq,uid)
except webalert.AlertError, e:
return input(req, idq, name, freq, notif, idb, e)
return page(title="Display alerts",
body=html,
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
description="CDS Personalize, Display alerts",
keywords="CDS, personalize",
uid=uid,
lastupdated=__lastupdated__)
def update(req, name, freq, notif, idb, bname, idq, old_idb):
uid = getUid(req)
try:
html=webalert.perform_update_alert(name, freq, notif, idb, bname, idq, old_idb,uid)
except webalert.AlertError, e:
return modify(req, idq, old_idb, name, freq, notif, idb, e)
return page(title="Display alerts",
body=html,
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
description="CDS Personalize, Display alerts",
keywords="CDS, personalize",
uid=uid,
lastupdated=__lastupdated__)
def remove(req, name, idu, idq, idb):
uid = getUid(req)
return page(title="Display alerts",
body=webalert.perform_remove_alert(name, idu, idq, idb, uid),
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
description="CDS Personalize, Display alerts",
keywords="CDS, personalize",
uid=uid,
lastupdated=__lastupdated__)

Event Timeline