Page MenuHomec4science

Get_Sysno.py
No OneTemporary

File Metadata

Created
Thu, May 16, 15:55

Get_Sysno.py

## $Id$
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
##
## CDS Invenio 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.
##
## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## Name: Get_Sysno.py
## Description: function Get_Sysno
## This function retrieves the system number of a document
## given its reference
## Author: T.Baron
## PARAMETERS: -
## OUTPUT: HTML
##
from invenio.search_engine import search_pattern
def Get_Sysno(parameters,curdir,form):
global rn,sysno
# initialize sysno variable
sysno = ""
if os.path.exists("%s/SN" % curdir):
fp = open("%s/SN" % curdir,"r")
sysno = fp.read()
fp.close()
else:
searchresults = search_pattern(req=None, p=rn, f="reportnumber").items().tolist()
if len(searchresults) == 0:
raise functionStop("<SCRIPT>document.forms[0].action=\"submit.py\";document.forms[0].curpage.value=1;document.forms[0].step.value=0;document.forms[0].submit();alert('The report %s cannot be found in our database.\\nPerhaps it has not been integrated yet?\\nAnyway, you can choose another report number if you wish.\\n Or retry this action in a few minutes.');</SCRIPT>" % rn)
elif len(searchresults) > 1:
raise functionStop("<SCRIPT>document.forms[0].action=\"submit.py\";document.forms[0].curpage.value=1;document.forms[0].step.value=0;document.forms[0].submit();alert('Multiple documents have been found with report number %s\\nYou can try with another report number if you wish.\\n Or retry this action in a few minutes.');</SCRIPT>" % rn)
else:
sysno = searchresults[0]
# save resultin a file
fp = open("%s/SN" % curdir,"w")
fp.write(str(sysno))
fp.close()
return ""

Event Timeline