Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86812996
index.py.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Oct 8, 18:35
Size
6 KB
Mime Type
text/x-c
Expires
Thu, Oct 10, 18:35 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
21484268
Attached To
R3600 invenio-infoscience
index.py.wml
View Options
## $Id$
## CDSware WebSubmit in mod_python.
## 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"
## start Python:
<protect>## $Id$</protect>
<protect>## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.</protect>
"""CDSware Submission Web Interface."""
## fill config variables:
pylibdir = "<LIBDIR>/python"
<protect>
## import interesting modules:
try:
import string
import os
import sys
import time
import MySQLdb
except ImportError, e:
print "Error: %s" % e
import sys
sys.exit(1)
try:
sys.path.append('%s' % pylibdir)
from cdsware.config import *
from cdsware.dbquery import run_sql
from cdsware.access_control_engine import acc_authorize_action
from cdsware.websubmit_config import *
from cdsware.webpage import page, create_error_box
from cdsware.webuser import getUid
from cdsware.messages import *
except ImportError, e:
print "Error: %s" % e
import sys
sys.exit(1)
def index(req,c=cdsname,ln=cdslang):
ln = wash_language(ln)
# get user ID:
try:
uid = getUid(req)
except MySQLdb.Error, e:
return page(title=msg_internal_error[ln],
body = create_error_box(req, verbose=0, ln=ln),
description="%s - Internal Error" % cdsname,
keywords="%s, CDSware, Internal Error" % cdsname,
language=ln,
urlargs=req.args)
# start display:
req.content_type = "text/html"
req.send_http_header()
finaltext = ""
finaltext = finaltext + """
<SCRIPT TYPE="text/javascript" LANGUAGE="Javascript1.2">
var allLoaded = 1;
</SCRIPT>
<BR>
<SMALL>
<STRONG class=headline>Notice:</STRONG><BR>
Please select the type of document you want to submit:
</SMALL>
<BR><BR>
<TABLE width="100%">
<TR>
<TD width="50%">
"""
finaltext = finaltext + "<FORM method=get action=\"%s/action.py\">\n" % urlpath
finaltext = finaltext + "<INPUT type=\"hidden\" name=\"doctype\">"
# Initialise catalogues array
finaltext = finaltext + makeCataloguesTable()
finaltext = finaltext + """
</TD>
<TD valign=top>
<DIV ID="TEXTWND"
STYLE="POSITION: relative; Z-INDEX: 20; VISIBILITY: hidden;">
</DIV>"""
for r in run_sql("SELECT sdocname,ldocname,description FROM sbmDOCTYPE"):
finaltext = finaltext + " <DIV ID=\"%s\" STYLE=\"POSITION: absolute; Z-INDEX: 20; VISIBILITY: hidden; WIDTH: 300;\">\n <SMALL><IMG SRC=\"%s/okay.gif\" ALT=\"\"><STRONG>%s:</STRONG></SMALL><BR><HR><SMALL>%s</SMALL><HR>\n </DIV>\n\n" % (r[0],images,r[1],r[2])
finaltext = finaltext + """
</TD>
</TR>
</TABLE>
</FORM>"""
return page(title="Submit",
body=finaltext,
description="toto",
keywords="keywords",
uid=uid,
language=ln,
urlargs=req.args
)
def makeCataloguesTable():
text = ""
catalogues = []
queryResult = run_sql("SELECT id_son FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_father=0 ORDER BY catalogue_order");
if len(queryResult) != 0:
# Query has executed successfully, so we can proceed to display all
# catalogues in the EDS system...
text = "<UL>\n"
for row in queryResult:
catalogues.append(row[0])
text = text + displayCatalogueBranch(row[0],1,catalogues)
text = text + "</UL>\n"
else:
text = "<h3>No catalogues yet...</h3>\n"
return text
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>%s\n" % row[0]
else:
if level > 2:
text = "<LI>%s\n" % row[0]
# display the son document types
res1 = run_sql("SELECT id_son FROM sbmCOLLECTION_sbmDOCTYPE WHERE id_father=%s ORDER BY catalogue_order" % id_father)
res2 = run_sql("SELECT id_son FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_father=%s ORDER BY catalogue_order" % id_father)
if len(res1) != 0 or len(res2) != 0:
text = text + "<UL>\n"
if len(res1) != 0:
for row in res1:
text = text + displayDoctypeBranch(row[0],catalogues)
# display the son catalogues
for row in res2:
catalogues.append(row[0])
text = text + displayCatalogueBranch(row[0],llevel+1,catalogues)
if len(res1) != 0 or len(res2) != 0:
text = text + "</UL>\n"
return text
def displayDoctypeBranch(doctype,catalogues):
text = ""
res = run_sql("SELECT ldocname FROM sbmDOCTYPE WHERE sdocname='%s'" % doctype)
row = res[0]
text = "<LI><small><a href=\"\" onmouseover=\"javascript:popUpTextWindow('%s',true,event);\" onmouseout=\"javascript:popUpTextWindow('%s',false,event);\" onClick=\"document.forms[0].doctype.value='%s';document.forms[0].submit();return false;\">%s</a></small>\n" % (doctype,doctype,doctype,row[0])
return text
</protect>
Event Timeline
Log In to Comment