rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
sql = 'INSERT INTO %s (session_key, session_expiry, session_object, uid) values ("%s","%s","%s","%s")' % \ (self.__class__.__tableName, self.id, self.get_access_time()+60*60*24*2, repr, int(self.getUid())) res = run_sql(sql)
sql = """INSERT INTO %s (session_key, session_expiry, session_object, uid) VALUES ("%s","%s","%s","%s")""" % \ (self.__class__.__tableName, self.id, self.get_access_time()+60*60*24*2, sessrepr, int(self.getUid())) run_sql(sql)
def save( self ): """method that tries to insert the session as NEW in the DB. If this fails (giving an integrity error) it means the session already exists there and it must be updated, so it performs the corresponding SQL update """ repr = self.__getRepr().replace("'", "\\\'") repr = repr.replace('"', '\\\"') try: s...
sql = 'UPDATE %s SET uid=%s, session_expiry=%s, session_object="%s" WHERE session_key="%s"' % \ (self.__class__.__tableName, int(self.getUid()), self.get_access_time()+60*60*24*2, repr, self.id) res = run_sql(sql)
sql = """UPDATE %s SET uid=%s, session_expiry=%s, session_object="%s" WHERE session_key="%s" """ % \ (self.__class__.__tableName, int(self.getUid()), self.get_access_time()+60*60*24*2, sessrepr, self.id) run_sql(sql)
def save( self ): """method that tries to insert the session as NEW in the DB. If this fails (giving an integrity error) it means the session already exists there and it must be updated, so it performs the corresponding SQL update """ repr = self.__getRepr().replace("'", "\\\'") repr = repr.replace('"', '\\\"') try: s...
except SessionNotInDb, e:
except SessionNotInDb:
def __includeItemFromDB(self, key): if key not in self.data.keys(): try: s = pSession.retrieve( key ) self.data[key] = s except SessionNotInDb, e: pass
format = re.sub("^[^\.]*\.","",fullname) if format == fullname: format = "" filename = re.sub("\.%s" % format,"",fullname) self.docfiles.append(BibDocFile(filepath,self.type,fileversion,filename,format,self.id))
fullname_last_dot_postition = fullname.rfind(".") if fullname_last_dot_postition == -1: fullname_basename = fullname fullname_extension = "" else: fullname_basename = fullname[:fullname_last_dot_postition] fullname_extension = fullname[fullname_last_dot_postition+1:] self.docfiles.append(BibDocFile(filepath,self.type,f...
def BuildFileList(self): """lists all files attached to the bibdoc""" self.docfiles = [] if os.path.exists(self.basedir): for fil in os.listdir(self.basedir): if fil != ".recid" and fil != ".docid" and fil != "." and fil != "..": filepath = "%s/%s" % (self.basedir,fil) fileversion = re.sub(".*;","",fil) fullname = fil....
if oldrn != "" and not re.match("\?\?\?",oldrn):
if oldrn != "" and not re.search("\?\?\?",oldrn):
def Report_Number_Generation(parameters,curdir,form): global doctype,access,act,dir,rn # The program must automatically generate the report number # Generate Year if parameters['autorngen'] == "Y": if parameters['yeargen'] == "AUTO": # Current year is used yy = time.strftime("%Y") else : # If yeargen != auto then the c...
self.buffer = self.buffer.decode('Shift_JIS', 'ignore').encode('utf-8', 'ignore')
self.buffer_decode_from('Shift_JIS')
def parse(self): """Parse buffer to extract records."""
s = datafield.getAttributeNS(None,"tag")
s = datafield.getAttributeNS(None,"tag").encode("utf-8")
def create_record_4suite(xmltext,verbose=verbose,correct=correct): """ creates a record object and returns it uses 4Suite domlette """ record = {} global err if correct: xmlt = xmltext (rec,e) = wash(xmlt,1) err.extend(e) return (rec,e) dom = NonvalidatingReader.parseString(xmltext,"urn:dummy") root = dom.childNode...
text=_("You are administrator of the following groups:") )
text=_("You are an administrator of the following groups:") )
def tmpl_display_admin_group(self, groups, ln=cdslang): """ Display the groups the user is admin of. Parameters:
group_text = self.tmpl_group_table_title(img="/img/webbasket_us.png", text=_("You are member of the following groups:"))
group_text = self.tmpl_group_table_title(img="/img/webbasket_us.png", text=_("You are a member of the following groups:"))
def tmpl_display_member_group(self, groups, ln=cdslang): """ Display the groups the user is member of. Parameters: - 'ln' *string* - The language to display the interface in - 'groups' *list* - All the group the user is member of """ _ = gettext_set_language(ln) group_text = self.tmpl_group_table_title(img="/img/webb...
label = _('Edit group: ') + group_name
label = _('Edit group %s') % group_name
def tmpl_display_input_group_info(self, group_name, group_description, join_policy, act_type="create", grpID="", warnings=[], ln=cdslang): """ Display group data when creating or updating a group: Name, description, join_policy. Parameters: - 'ln' *string* - The language to display the interface in - 'group_name' *stri...
member_text = """<td style="padding: 0 5 10 5;" collspan="2">%s</td>""" % _("No member")
member_text = """<td style="padding: 0 5 10 5;" collspan="2">%s</td>""" % _("No members.")
def tmpl_display_manage_member(self, grpID, group_name, members, pending_members, infos=[], warnings=[], ln=cdslang): """Display current members and waiting members of a group. Parameters:
pending_text = """<td style="padding: 0 5 10 5;" collspan="2">%s</td>""" % _("No waiting member")
pending_text = """<td style="padding: 0 5 10 5;" collspan="2">%s</td>""" % _("No members awaiting approval.")
def tmpl_display_manage_member(self, grpID, group_name, members, pending_members, infos=[], warnings=[], ln=cdslang): """Display current members and waiting members of a group. Parameters:
header2 = self.tmpl_group_table_title(text=_("Waiting members"))
header2 = self.tmpl_group_table_title(text=_("Members awaiting approval"))
def tmpl_display_manage_member(self, grpID, group_name, members, pending_members, infos=[], warnings=[], ln=cdslang): """Display current members and waiting members of a group. Parameters:
out %= {'title':_('Group: <b>%s</b>') % group_name,
out %= {'title':_('Group: %s') % group_name,
def tmpl_display_manage_member(self, grpID, group_name, members, pending_members, infos=[], warnings=[], ln=cdslang): """Display current members and waiting members of a group. Parameters:
subject = _("Group %s: New user request") % group_name
subject = _("Group %s: New membership request") % group_name
def tmpl_admin_msg(self, group_name, grpID, ln=cdslang): """ return message content for joining group - 'group_name' *string* - name of the group - 'grpID' *string* - ID of the group - 'ln' *string* - The language to display the interface in """ _ = gettext_set_language(ln) subject = _("Group %s: New user request") % g...
body = (_("A new user wants to join group %s.") % group_name) + '<br/>' body += (_("You can %saccept or reject%s the new member") % ('<a href="' + url + '">', '</a>')) + '<br />'
body = (_("A user wants to join the group %s.") % group_name) + '<br/>' body += (_("Please %saccept or reject%s this user's request.") % ('<a href="' + url + '">', '</a>')) + '<br />'
def tmpl_admin_msg(self, group_name, grpID, ln=cdslang): """ return message content for joining group - 'group_name' *string* - name of the group - 'grpID' *string* - ID of the group - 'ln' *string* - The language to display the interface in """ _ = gettext_set_language(ln) subject = _("Group %s: New user request") % g...
_("Cited by"),
{}, _("Cited by"),
def tmpl_print_record_brief_links(self, ln, recID, weburl): """Displays links for brief record on-the-fly
write_messag("New size: %s" % len(rec_dict))
write_message("New size: %s" % len(rec_dict))
def del_recids(rank_method_code, range): """Delete some records from the rank method""" id = run_sql("SELECT id from rnkMETHOD where name='%s'" % rank_method_code) res = run_sql("SELECT relevance_data FROM rnkMETHODDATA WHERE id_rnkMETHOD=%s" % id[0][0]) if res: rec_dict = deserialize_via_marshal(res[0][0]) write_messa...
def create_header(cc=cdsname, as=0, headeradd=""):
def create_header(cc=cdsname, as=0, uid=0, headeradd=""):
def create_header(cc=cdsname, as=0, headeradd=""): "Creates CDS header and info on URL and date." return """
cdspageheader, \
re.sub("<!--USERINFOBOX-->", create_user_infobox(uid), cdspageheader),
def create_header(cc=cdsname, as=0, headeradd=""): "Creates CDS header and info on URL and date." return """
"","&gt;","", "&gt; Search Results</td></tr></table><br>",0), \
"","&gt;","", "&gt; Search Results</td></tr></table><br>",0),
def create_header(cc=cdsname, as=0, headeradd=""): "Creates CDS header and info on URL and date." return """
if cfg_google_box: out += create_google_box(p, f, p1, p2, p3)
def create_search_box(cc, colls, p, f, rg, sf, so, sp, of, ot, as, p1, f1, m1, op1, p2, f2, m2, op2, p3, f3, m3, sc, d1y, d1m, d1d, d2y, d2m, d2d, action="SEARCH"): "Create search box for 'search again in the results page' functionality." out = "" # print search box prolog: out += """ <form action="%s/search.py" method...
colls_nicely_ordered = get_nicely_ordered_collection_list()
colls_nicely_ordered = [] if cfg_nicely_ordered_collection_list: colls_nicely_ordered = get_nicely_ordered_collection_list() else: colls_nicely_ordered = get_alphabetically_ordered_collection_list()
def create_search_box(cc, colls, p, f, rg, sf, so, sp, of, ot, as, p1, f1, m1, op1, p2, f2, m2, op2, p3, f3, m3, sc, d1y, d1m, d1d, d2y, d2m, d2d, action="SEARCH"): "Create search box for 'search again in the results page' functionality." out = "" # print search box prolog: out += """ <form action="%s/search.py" method...
out += """</table></form> """
out += """</form>"""
def create_search_box(cc, colls, p, f, rg, sf, so, sp, of, ot, as, p1, f1, m1, op1, p2, f2, m2, op2, p3, f3, m3, sc, d1y, d1m, d1d, d2y, d2m, d2d, action="SEARCH"): "Create search box for 'search again in the results page' functionality." out = "" # print search box prolog: out += """ <form action="%s/search.py" method...
prolog="""<table align="right" class="googlebox"><tr><th class="googleboxheader">Try your search on:</th></tr><tr><td class="googleboxbody">""",
prolog="""<table class="googlebox"><tr><th class="googleboxheader">Try your search on:</th></tr><tr><td class="googleboxbody">""",
def create_google_box(p, f, p1, p2, p3, prolog="""<table align="right" class="googlebox"><tr><th class="googleboxheader">Try your search on:</th></tr><tr><td class="googleboxbody">""", separator= """<br>""", epilog="""</td></tr></table>"""): "Creates the box that proposes links to other useful search engines like Googl...
if cfg_google_box == 1:
if cfg_google_box:
def create_google_box(p, f, p1, p2, p3, prolog="""<table align="right" class="googlebox"><tr><th class="googleboxheader">Try your search on:</th></tr><tr><td class="googleboxbody">""", separator= """<br>""", epilog="""</td></tr></table>"""): "Creates the box that proposes links to other useful search engines like Googl...
try again below <a href="%s/search.py?search=Browse&p=%s&f=%s%s">%s</a>
<a href="%s/search.py?search=Browse&p=%s&f=%s%s">browse further</a>
def browse_in_bibxxx(req, colls, p, f, rg): """Browse bibliographic phrases for the given pattern in the given field.""" ## determine browse field: if string.find(p, ":") > 0: # does 'p' contain ':'? f, p = split(p, ":", 2) ## prepare collection urlargument for later printing: urlarg_colls = "" for coll in colls: urlar...
% (weburl, weburl, urllib.quote(word_try), urllib.quote(f), urlarg_colls, word_try))
% (weburl, weburl, urllib.quote(word_try), urllib.quote(f), urlarg_colls))
def browse_in_bibxxx(req, colls, p, f, rg): """Browse bibliographic phrases for the given pattern in the given field.""" ## determine browse field: if string.find(p, ":") > 0: # does 'p' contain ':'? f, p = split(p, ":", 2) ## prepare collection urlargument for later printing: urlarg_colls = "" for coll in colls: urlar...
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0):
def search_pattern(req, p=None, f=None, colls=[], m=None, hit_hints=0):
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
results = HitList() results_used = 0
results_out = {} for coll in colls: results_out[coll] = HitList() results_out[coll]._nbhits = 0
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
results_out = {}
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
results_out[coll] = HitList()
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
hit_hints_displayed = 0
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
return(1)
return None
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
hit_hints_displayed = 1
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
(text, create_nearest_words_links(req.args, pi, fi)), "")
(text, create_nearest_words_links(req.args, pi, fi)), "") return results_out
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
if results_used:
if results_in_any_collection_empty: results_in_any_collection = results_for_opft_item results_in_any_collection_empty = 0 else:
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
results.intersect(results_for_opft_item)
results_in_any_collection.intersect(results_for_opft_item)
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
results.difference(results_for_opft_item)
results_in_any_collection.difference(results_for_opft_item)
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
results.union(results_for_opft_item)
results_in_any_collection.union(results_for_opft_item)
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
else: results = results_for_opft_item results_used = 1
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
if colls == None: results.calculate_nbhits() return results if dbg: t1 = os.times()[4] results_out = {} if colls: for coll in colls: results_out[coll] = HitList() results_out[coll]._set = Numeric.bitwise_and(results._set, collrecs_cache[coll]._set) if dbg: t2 = os.times()[4] print_warning(req, "Intersecting with coll...
if colls == []: return results_in_any_collection if results_in_any_collection._nbhits == 0: if hit_hints:
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
print_warning(req, text, "") else: num = 0 for coll in colls: num += results_out[coll]._nbhits if num == 0: results_Home = HitList() results_Home._set = Numeric.bitwise_and(results._set, collrecs_cache[cdsname]._set) results_Home.calculate_nbhits() if results_Home._nbhits > 0: url_args = req.args url_args = re.sub(r'...
print_warning(req, text, "") return results_out if dbg: t1 = os.times()[4] if colls: for coll in colls: results_out[coll]._set = Numeric.bitwise_and(results_in_any_collection._set, collrecs_cache[coll]._set) if dbg: t2 = os.times()[4] print_warning(req, "Intersecting with collection hitlist universe took %.2f seconds...
def search_pattern(req, p=None, f=None, colls=None, m=None, hit_hints=0): """Searches for pattern 'p' and field 'f' and returns dict of recIDs HitLists per each collection in 'colls'. - Optionally, the function accepts the match type argument 'm'. If it is set (e.g. from advanced search interface), then it performs thi...
"""Prints stripe with the information on 'collection' and 'nb_found' results and CPU time.
"""Prints stripe with the information on 'collection' and 'nb_found' results oand CPU time.
def print_search_info(p, f, sf, so, sp, of, ot, collection=cdsname, nb_found=-1, jrec=1, rg=10, as=0, p1="", p2="", p3="", f1="", f2="", f3="", m1="", m2="", m3="", op1="", op2="", d1y="", d1m="", d1d="", d2y="", d2m="", d2d="", cpu_time=-1, middle_only=0): """Prints stripe with the information on 'collection' and 'nb_...
time.strftime("%04Y-%02m-%02d %02H%:02M:%02S", time.localtime())))
time.strftime("%04Y-%02m-%02d %02H:%02M:%02S", time.localtime())))
def log_query(hostname, query_args, uid=-1): """Log query into the query and user_query tables.""" if uid > 0: # log the query only if uid is reasonable res = run_sql("SELECT id FROM query WHERE urlargs=%s", (query_args,), 1) try: id_query = res[0][0] except: id_query = run_sql("INSERT INTO query (type, urlargs) VALUES...
try: uid = getUid(req) req.write(create_header(cc, as, create_user_infobox(uid))) except: req.write(create_header(cc, as))
req.write(create_header(cc, as, uid))
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", id="-1", idb="-1", sysnb="", search="SEARCH", d1y="", d1m="", d1d="", d2y="", d2m="", d2d=""): """P...
req.write(create_search_box(cc, colls_to_display, p, f, rg, sf, so, sp, of, ot, as, p1, f1, m1, op1, p2, f2, m2, op2, p3, f3, m3, sc, d1y, d1m, d1d, d2y, d2m, d2d, search))
out = """<table width="100%%" cellspacing="0" cellpadding="0" border="0"> <tr valign="top"> <td> %s </td> <td class="pagestriperight"> %s </td> </tr> </table>""" % \ (create_search_box(cc, colls_to_display, p, f, rg, sf, so, sp, of, ot, as, p1, f1, m1, op1, p2, f2, m2, op2, p3, f3, m3, sc, d1y, d1m, d1d, d2y, d2m, d2d,...
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", id="-1", idb="-1", sysnb="", search="SEARCH", d1y="", d1m="", d1d="", d2y="", d2m="", d2d=""): """P...
return self.new_session(request, id)
return self.new_session(request, sessid)
def _create_session (self, request): # Generate a session ID, which is just the value of the session # cookie we are about to drop on the user. (It's also the key # used with the session manager mapping interface.) sessid = None while sessid is None or self.has_session(sessid): sessid = "%016X" % randlong(8) # 64-bit...
def add_record_to_basket(record_id, basket_id): try: return run_sql('insert into basket_record (id_basket, id_record) values(%s, %s);', (basket_id, record_id,)) except:
def add_records_to_basket(record_ids, basket_id): global DEBUGLEVEL nrec = len(record_ids) if nrec > 0: vals = '(%s,%s)' % (basket_id, record_ids[0]) if nrec > 1: for i in record_ids[1:]: vals += ',(%s, %s)' % (basket_id, i) if DEBUGLEVEL > 0: print "-> adding %s records into basket %s: %s" % (nrec, basket_id, vals) ...
def add_record_to_basket(record_id, basket_id): try: return run_sql('insert into basket_record (id_basket, id_record) values(%s, %s);', (basket_id, record_id,)) except: return 0
def add_records_to_basket(record_ids, basket_id): for i in record_ids: add_record_to_basket(i, basket_id)
def add_record_to_basket(record_id, basket_id): try: return run_sql('insert into basket_record (id_basket, id_record) values(%s, %s);', (basket_id, record_id,)) except: return 0
server.set_debuglevel(0)
if DEBUGLEVEL > 2: server.set_debuglevel(1) else: server.set_debuglevel(0)
def send_email(fromaddr, toaddr, body): server = smtplib.SMTP('smtp.cern.ch') server.set_debuglevel(0) server.sendmail(fromaddr, toaddr, body) server.quit()
msg = "\nHello\n\nBelow are the results of the email alert that you set up with the CERN Document Server:\n"
msg = "" if DEBUGLEVEL > 0: msg = "*** THIS MESSAGE WAS SENT IN DEBUG MODE, DON'T TAKE IT INTO ACCOUNT ***\n\n" msg += "Hello\n\nBelow are the results of the email alert that you set up with the CERN Document Server:\n"
def email_notify(alert, records, argstr): global FROMADDR global ALERTURL global DEBUGLEVEL if len(records) == 0: return msg = "\nHello\n\nBelow are the results of the email alert that you set up with the CERN Document Server:\n" email = get_email(alert[0]) url = weburl + "/search.py?" + argstr pattern = get_pattern...
msg += '\nalert name : \'%s\'' % alert[5] msg += '\npattern : \'%s\'' % pattern msg += '\ncatalogue(s) : %s' % catalogue msg += '\nfrequency : %s ' % format_frequency(alert[3]) msg += '\nrun time : %s ' % strftime("%c")
msg += '\nalert name: \'%s\'' % alert[5] msg += '\npattern: \'%s\'' % pattern msg += '\ncatalogue(s): %s' % catalogue msg += '\nfrequency: %s ' % format_frequency(alert[3]) msg += '\nrun time: %s ' % strftime("%c") msg += '\nfound: %s record(s)' % len(records)
def email_notify(alert, records, argstr): global FROMADDR global ALERTURL global DEBUGLEVEL if len(records) == 0: return msg = "\nHello\n\nBelow are the results of the email alert that you set up with the CERN Document Server:\n" email = get_email(alert[0]) url = weburl + "/search.py?" + argstr pattern = get_pattern...
time = (2002, 12, 21, 2, 0, 0, 2, 120, 1)
def run_query(query, frequency): """Return a dictionary containing the information of the performed query. The information contains the id of the query, the arguments as a string, and the list of found records.""" time = localtime() # Override time here for testing purposes (beware of localtime offset): #time = (2003...
frequency = 'week'
def run_query(query, frequency): """Return a dictionary containing the information of the performed query. The information contains the id of the query, the arguments as a string, and the list of found records.""" time = localtime() # Override time here for testing purposes (beware of localtime offset): #time = (2003...
cmd = "%s %s %s.txt" % (conv_program, tmp_name, tmp_name)
cmd = "%s -enc UTF-8 %s %s.txt" % (conv_program, tmp_name, tmp_name)
def get_words_from_fulltext(url_direct_or_indirect, separators="[^\w]", split=string.split, force_file_extension=None): """Returns all the words contained in the document specified by URL_DIRECT_OR_INDIRECT with the words being split by SEPARATORS. If FORCE_FILE_EXTENSION is set (e.g. to "pdf", then treat URL_DIRECT_O...
result += ' /&gt;'
self.result += ' /&gt;'
def handle_startendtag(self, tag, attrs): """Function called for empty tags (e.g. <br />)""" if tag.lower() in self.allowed_tag_whitelist: self.result += '<' + tag for (attr, value) in attrs: if attr.lower() in self.allowed_attribute_whitelist: self.result += ' %s="%s"' % \ (attr, self.handle_attribute_value(value)) s...
output = ""
def perform_switchfmtscore(colID, type, id_1, id_2, ln=cdslang): """Switch the score of id_1 and id_2 in the table type. colID - the current collection id_1/id_2 - the id's to change the score for. type - like "format" """ output = "" fmt_dict = dict(get_def_name('', "format")) res = switch_score(colID, id_1, id_2, ty...
output += write_outcome(res)
output = write_outcome(res)
def perform_switchfmtscore(colID, type, id_1, id_2, ln=cdslang): """Switch the score of id_1 and id_2 in the table type. colID - the current collection id_1/id_2 - the id's to change the score for. type - like "format" """ output = "" fmt_dict = dict(get_def_name('', "format")) res = switch_score(colID, id_1, id_2, ty...
output += write_outcome(res)
output = write_outcome(res)
def perform_switchfldscore(colID, id_1, id_2, fmeth, ln=cdslang): """Switch the score of id_1 and id_2 in collection_field_fieldvalue. colID - the current collection id_1/id_2 - the id's to change the score for.""" fld_dict = dict(get_def_name('', "field")) res = switch_fld_score(colID, id_1, id_2) output += write_out...
output += write_outcome(res)
output = write_outcome(res)
def perform_switchfldvaluescore(colID, id_1, id_fldvalue_1, id_fldvalue_2, ln=cdslang): """Switch the score of id_1 and id_2 in collection_field_fieldvalue. colID - the current collection id_1/id_2 - the id's to change the score for.""" name_1 = run_sql("SELECT name from fieldvalue where id=%s" % id_fldvalue_1)[0][0] ...
status = """<b><span class="warning">ERROR 1:Query</span></b>"""
status = """<b><span class="warning">1:Query</span></b>"""
def perform_validateconf(colID, ln, confirm=0, callback='yes'): """Validation of the configuration of the collections""" subtitle = """<a name="11"></a>Collections Status""" output = "" colID = int(colID) col_dict = dict(get_def_name('', "collection")) collections = run_sql("SELECT id, name, dbquery, restricted FROM...
status = """<b><span class="warning">ERROR 2:Query</span></b>"""
status = """<b><span class="warning">2:Query</span></b>"""
def perform_validateconf(colID, ln, confirm=0, callback='yes'): """Validation of the configuration of the collections""" subtitle = """<a name="11"></a>Collections Status""" output = "" colID = int(colID) col_dict = dict(get_def_name('', "collection")) collections = run_sql("SELECT id, name, dbquery, restricted FROM...
status = """<b><span class="warning">ERROR 3:Query</span></b>"""
status = """<b><span class="warning">3:Query</span></b>"""
def perform_validateconf(colID, ln, confirm=0, callback='yes'): """Validation of the configuration of the collections""" subtitle = """<a name="11"></a>Collections Status""" output = "" colID = int(colID) col_dict = dict(get_def_name('', "collection")) collections = run_sql("SELECT id, name, dbquery, restricted FROM...
status += """<b><span class="warning">ERROR 4:Restricted</span></b>"""
status += """<b><span class="warning">4:Restricted</span></b>"""
def perform_validateconf(colID, ln, confirm=0, callback='yes'): """Validation of the configuration of the collections""" subtitle = """<a name="11"></a>Collections Status""" output = "" colID = int(colID) col_dict = dict(get_def_name('', "collection")) collections = run_sql("SELECT id, name, dbquery, restricted FROM...
return webuser.page_not_authorized(req, "../youraccount.py/login") uid = webuser.getUid(req) _ = gettext_set_language(ln) if action == _('login'): if p_email==None or not login_method: return page(title=_("Login"),
return webuser.page_not_authorized(req, "../youraccount.py/login?ln=%s" % ln) uid = webuser.getUid(req) _ = gettext_set_language(ln) if action == "login" or action == _("login"): if p_email==None or not login_method: return page(title=_("Login"),
def login(req, p_email=None, p_pw=None, login_method=None, action='login', referer='', ln=cdslang): if CFG_ACCESS_CONTROL_LEVEL_SITE > 0: return webuser.page_not_authorized(req, "../youraccount.py/login") uid = webuser.getUid(req) # load the right message language _ = gettext_set_language(ln) if action == _('login'...
(iden, p_email, p_pw, msgcode) = webuser.loginUser(req,p_email,p_pw, login_method) if len(iden)>0: uid = webuser.update_Uid(req,p_email,p_pw) uid2 = webuser.getUid(req) if uid2 == -1: webuser.logoutUser(req) return webuser.page_not_authorized(req, "../youraccount.py/login?ln=%s" % ln, uid=uid) if referer: req.err_he...
(iden, p_email, p_pw, msgcode) = webuser.loginUser(req,p_email,p_pw, login_method) if len(iden)>0: uid = webuser.update_Uid(req,p_email,p_pw) uid2 = webuser.getUid(req) if uid2 == -1: webuser.logoutUser(req) return webuser.page_not_authorized(req, "../youraccount.py/login?ln=%s" % ln, uid=uid) if referer: req.err_he...
def login(req, p_email=None, p_pw=None, login_method=None, action='login', referer='', ln=cdslang): if CFG_ACCESS_CONTROL_LEVEL_SITE > 0: return webuser.page_not_authorized(req, "../youraccount.py/login") uid = webuser.getUid(req) # load the right message language _ = gettext_set_language(ln) if action == _('login'...
if record_exist_p == -1:
if format == '': format = 'hd' if record_exist_p == -1 and get_output_format_content_type(format) == 'text/html':
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress, search_pattern=None, uid=None): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # ...
if format == '': format = 'hd'
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress, search_pattern=None, uid=None): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # ...
if res:
if res and not record_exist_p == -1:
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress, search_pattern=None, uid=None): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # ...
elif format.startswith("x_"): out += call_bibformat(recID, format)
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # print record opening tags, if ...
if cfg_call_bibformat: xfm = call_bibformat(recID, format) dom = minidom.parseString(xfm) for e in dom.getElementsByTagName('subfield'): if e.getAttribute('code') == 'g': for t in e.childNodes: out += t.data.encode('utf-8')
out_record_in_format = call_bibformat(recID, format) if out_record_in_format: out += out_record_in_format
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # print record opening tags, if ...
out += websearch_templates.tmpl_print_record_brief( ln = ln, recID = recID, weburl = weburl, )
if cfg_call_bibformat: out_record_in_format = call_bibformat(recID, format) if out_record_in_format: out += out_record_in_format else: out += websearch_templates.tmpl_print_record_brief( ln = ln, recID = recID, weburl = weburl, ) else: out += websearch_templates.tmpl_print_record_brief( ln = ln, recID = recID, weburl =...
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # print record opening tags, if ...
def call_bibformat(id, otype="HD"): """Calls BibFormat for the record 'id'. Desired BibFormat output type is passed in 'otype' argument. This function is mainly used to display full format, if they are not stored in the 'bibfmt' table.""" pipe_input, pipe_output, pipe_error = os.popen3(["%s/bibformat" % bindir, "otype...
def call_bibformat(recID, format="HD"): """Calls BibFormat for the record RECID in the desired output format FORMAT. This function is mainly used to display all but brief formats, if they are not stored in the 'bibfmt' table. Note: this functions always try to return HTML, so when bibformat returns XML with embedded H...
def call_bibformat(id, otype="HD"): """Calls BibFormat for the record 'id'. Desired BibFormat output type is passed in 'otype' argument. This function is mainly used to display full format, if they are not stored in the 'bibfmt' table.""" pipe_input, pipe_output, pipe_error = os.popen3(["%s/bibformat" % bindir, "otype...
out = pipe_output.read()
bibformat_output = pipe_output.read()
def call_bibformat(id, otype="HD"): """Calls BibFormat for the record 'id'. Desired BibFormat output type is passed in 'otype' argument. This function is mainly used to display full format, if they are not stored in the 'bibfmt' table.""" pipe_input, pipe_output, pipe_error = os.popen3(["%s/bibformat" % bindir, "otype...
If needed, the check 'type(var) is not None' should be done before calling this function
If needed, the check 'type(var) is not None' should be done before calling this function.
def wash_url_argument(var, new_type): """ Wash argument into 'new_type', that can be 'list', 'str', 'int', 'tuple' or 'dict'. If needed, the check 'type(var) is not None' should be done before calling this function @param var: variable value @param new_type: variable type, 'list', 'str', 'int', 'tuple' or 'dict' @retur...
Redirect current page to url
Redirect current page to url.
def redirect_to_url(req, url): """ Redirect current page to url @param req: request as received from apache @param url: url to redirect to""" req.err_headers_out.add("Location", url) raise apache.SERVER_RETURN, apache.HTTP_MOVED_PERMANENTLY
from webpage import page
from cdsware.webpage import page
def page_not_authorized(req, referer='', uid='', text='', navtrail=''): """Show error message when account is not activated""" from webpage import page if not CFG_ACCESS_CONTROL_LEVEL_SITE: title = cfg_webaccess_msgs[5] if not uid: uid = getUid(req) res = run_sql("SELECT email FROM user WHERE id=%s" % uid) if res and ...
from search_engine import coll_restricted_p, coll_restricted_group
from cdsware.search_engine import coll_restricted_p, coll_restricted_group
def auth_apache_user_collection_p(user, password, coll): """Check whether user-supplied credentials correspond to valid Apache password data file, and whether this user is authorized to see the given collections. Return 0 in case of failure, 1 in case of success.""" from search_engine import coll_restricted_p, coll_re...
text = text + displayCatalogueBranch(row[0],llevel+1,catalogues)
text = text + displayCatalogueBranch(row[0],level+1,catalogues)
def displayCatalogueBranch(id_father,level,catalogues): text = "" queryResult = run_sql("SELECT name, id FROM sbmCOLLECTION WHERE id=%s", (id_father,)) if len(queryResult) != 0: row = queryResult[0] if level == 1: text = "<LI><font size=\"+1\"><strong>%s</strong></font>\n" % row[0] else: if level == 2: text = "<LI>%...
except UnicodedecodeError:
except UnicodeDecodeError:
def processLine(self, line): """Transform accents in a line into correct format""" try: for x in self._patterns.keys(): try: line = line.replace(x, self._patterns[x]) except UnicodedecodeError: sys.exit(0) except TypeError: pass return line
except Error:
except:
def recxml2recmarc(xmltext, options): """The function that processes creating the records from an XML string, and prints these records to the standard output stream. @param xmltext: An XML MARC record in string form. @param options: Various options about the record to be created, as passed from the command line. @retur...
psyco.bind(post_calculate_record_relevance)
def rank_method_stat(rank_method_code, reclist, lwords): """Shows some statistics about the searchresult. rank_method_code - name field from rnkMETHOD reclist - a list of sorted and ranked records lwords - the words in the query""" global voutput if len(reclist) > 20: j = 20 else: j = len(reclist) voutput += "<br>Ran...
print 'Error connecting to SMTP server, attempt %s retrying in 5 minutes.' % attempt
print 'Error connecting to SMTP server, attempt %s retrying in 5 minutes. Exception raised: %s' % (attempt, sys.exc_info()[0])
def send_email(fromaddr, toaddr, body, attempt=0): global DEBUGLEVEL if attempt > 2: log('error sending email to %s: SMTP error; gave up after 3 attempts' % toaddr) return try: server = smtplib.SMTP('localhost') if DEBUGLEVEL > 2: server.set_debuglevel(1) else: server.set_debuglevel(0) server.sendmail(fromaddr, toad...
msg += '\n\n' + wrap('Only the first %s records are displayed above. Please consult the URL below to see all the results.' % MAXIDS)
msg += '\n\n' + wrap('Only the first %s records were displayed. Please consult the search URL given at the top of this email to see all the results.' % MAXIDS)
def print_records(record_ids): global MAXIDS msg = '' c = 1 for i in record_ids: if c > MAXIDS: break msg += '\n\n%s) %s' % (c, get_as_text(i)) c += 1 if c > MAXIDS: msg += '\n\n' + wrap('Only the first %s records are displayed above. Please consult the URL below to see all the results.' % MAXIDS) return msg
msg = "*** THIS MESSAGE WAS SENT IN DEBUG MODE, DON'T TAKE IT INTO ACCOUNT ***\n\n"
msg = "*** THIS MESSAGE WAS SENT IN DEBUG MODE ***\n\n"
def email_notify(alert, records, argstr): global FROMADDR global ALERTURL global DEBUGLEVEL global DEVELOPERADDR if len(records) == 0: return msg = "" if DEBUGLEVEL > 0: msg = "*** THIS MESSAGE WAS SENT IN DEBUG MODE, DON'T TAKE IT INTO ACCOUNT ***\n\n" msg += "Hello\n\n" msg += wrap("Below are the results of the e...
return page(title=_("View all reported comments")), body=perform_request_comments(ln=ln, uid=uid, comID=comid, reviews=reviews), uid=auid, language=ln, navtrail = navtrail_previous_links, lastupdated=__lastupdated__, req=req)
return page(title=_("View all reported comments"), body=perform_request_comments(ln=ln, uid=uid, comID=comid, reviews=reviews), uid=auid, language=ln, navtrail = navtrail_previous_links, lastupdated=__lastupdated__, req=req)
def comments(req, ln=cdslang, uid="", comid="", reviews=0): """ View reported comments, filter by either user or a specific comment (only one given at a time) @param ln: language @param uid: user id @param comid: comment id @param reviews: boolean enabled for reviews, disabled for comments """ ln = wash_language(ln) _ ...
id_basket = yourbaskets.perform_create_basket(new_basket_name)
id_basket = perform_create_basket(uid, new_basket_name)
def perform_add_alert(alert_name, frequency, notification, id_basket, new_basket_name, id_query,uid): # set variables out = "" id_user=uid # XXX # set the basket identifier if new_basket_name != "": # create a new basket id_basket = yourbaskets.perform_create_basket(new_basket_name) out += """The <I>private</I> bask...
run_alerts_queries_for_user(60)
process_alert_queries_for_user(60)
def run_alerts(uid): process_alert_queries_for_user(uid)
list_title ="Cited&nbsp;By&nbsp;%s&nbsp;record"% len(citing_list)
list_title ="Cited&nbsp;By&nbsp;%s&nbsp;records"% len(citing_list)
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
list_title ="Co-Cited&nbsp;With&nbsp;%s&nbsp;record"% len(reclist)
list_title ="Co-Cited&nbsp;With&nbsp;%s&nbsp;records"% len(reclist)
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
list_title = "People&nbsp;who&nbsp;downloaded&nbsp;this&nbsp;record&nbsp;also&nbsp;downloaded&nbsp;:"
list_title = "People&nbsp;who&nbsp;downloaded&nbsp;this&nbsp;record&nbsp;also&nbsp;downloaded:"
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
list_title = "People&nbsp;who&nbsp;viewed&nbsp;this&nbsp;page&nbsp;also&nbsp;viewed&nbsp;:"
list_title = "People&nbsp;who&nbsp;viewed&nbsp;this&nbsp;page&nbsp;also&nbsp;viewed:"
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
out += """<a href="http://cdswebdev.cern.ch/search.py?recid=%s&ln=en">""" %recID
out += """<a href="%s/search.py?recid=%s&ln=en">""" % (weburl, recID)
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress): "Prints record 'recID' formatted accoding to 'format'." out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # print record opening tags, if needed: if format == "marcxml" ...
print_records(req, range(recid,recidb), -1, -9999, of, ot, ln)
print_records(req, range(recid,recidb), -1, -9999, of, ot, ln) if req and of.startswith("h"): client_ip_address = str(req.get_remote_host(apache.REMOTE_NOLOOKUP)) run_sql("INSERT INTO rnkPAGEVIEWS (id_bibrec,id_user,client_host,view_time) VALUES (%s,%s,INET_ATON(%s),NOW())", (recid, uid, client_ip_address))
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", rm="", of="id", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="", d1y="0", d1m="0",...
if not wsc.check_user(uid):
if not wsc.check_user(uid, 'cfgwebsearch'):
def switchfmtscore(req, colID, type, id_1, id_2, ln=cdslang): navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class=navtrail href="%s/admin/websearch/websearchadmin.py/">Edit Collection Tree</a> """ % (weburl) try: uid = getUid(req) except MySQLdb.Error, e: return error_page(req) if not wsc.check_user(uid): ...
if not wsc.check_user(uid):
if not wsc.check_user(uid, 'cfgwebsearch'):
def switchfldscore(req, colID, id_1, id_2, fmeth, ln=cdslang): navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class=navtrail href="%s/admin/websearch/websearchadmin.py/">Edit Collection Tree</a> """ % (weburl) try: uid = getUid(req) except MySQLdb.Error, e: return error_page(req) if not wsc.check_user(uid):...
if not wsc.check_user(uid):
if not wsc.check_user(uid, 'cfgwebsearch'):
def switchfldvaluescore(req, colID, id_1, id_fldvalue_1, id_fldvalue_2, ln=cdslang): navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class=navtrail href="%s/admin/websearch/websearchadmin.py/">Edit Collection Tree</a> """ % (weburl) try: uid = getUid(req) except MySQLdb.Error, e: return error_page(req) if no...
if not wsc.check_user(uid):
if not wsc.check_user(uid, 'cfgwebsearch'):
def switchpbxscore(req, colID, id_1, id_2, sel_ln,ln=cdslang): navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class=navtrail href="%s/admin/websearch/websearchadmin.py/">Edit Collection Tree</a> """ % (weburl) try: uid = getUid(req) except MySQLdb.Error, e: return error_page(req) if not wsc.check_user(uid):...
if not wsc.check_user(uid):
if not wsc.check_user(uid, 'cfgwebsearch'):
def modifydbquery(req, colID, ln=cdslang, dbquery='', confirm=-1): navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class=navtrail href="%s/admin/websearch/websearchadmin.py/">Edit Collection Tree</a> """ % (weburl) try: uid = getUid(req) except MySQLdb.Error, e: return error_page(req) if not wsc.check_user(u...