Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85068793
Make_Modify_Record.py
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
Thu, Sep 26, 13:58
Size
2 KB
Mime Type
text/x-python
Expires
Sat, Sep 28, 13:58 (2 d)
Engine
blob
Format
Raw Data
Handle
21124861
Attached To
R3600 invenio-infoscience
Make_Modify_Record.py
View Options
## $Id$
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 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.
__revision__
=
"$Id$"
## Description: function Make_Modify_Record
## This function creates the bibliographic record
## using bibConvert and the configuration files passed as
## parameters
## Author: T.Baron
##
## PARAMETERS: sourceModify: source description file
## mysqlModify: template description file
## OUTPUT: HTML
import
os
from
invenio.config
import
\
bibconvert
,
\
bibconvertconf
from
invenio.websubmit_config
import
InvenioWebSubmitFunctionError
def
Make_Modify_Record
(
parameters
,
curdir
,
form
):
# Get rid of "invisible" white spaces
source
=
parameters
[
'sourceTemplate'
]
.
replace
(
" "
,
""
)
modify
=
parameters
[
'modifyTemplate'
]
.
replace
(
" "
,
""
)
# We use bibconvert to create the xml record
call_uploader_txt
=
"
%s
-l1 -d'
%s
' -Cs'
%s
/
%s
' -Ct'
%s
/
%s
' >
%s
/recmysql"
%
(
bibconvert
,
curdir
,
bibconvertconf
,
source
,
bibconvertconf
,
modify
,
curdir
)
os
.
system
(
call_uploader_txt
)
# Then we have to format this record (turn & into & and < into <
# After all we know nothing about the text entered by the users at submission time
if
os
.
path
.
exists
(
"
%s
/recmysql"
%
curdir
):
fp
=
open
(
"
%s
/recmysql"
%
curdir
,
"r"
)
rectext
=
fp
.
read
()
fp
.
close
()
else
:
raise
InvenioWebSubmitFunctionError
(
"Cannot create database record"
)
# First of all the &
rectext
=
rectext
.
replace
(
"&"
,
"&"
)
rectext
=
rectext
.
replace
(
"&"
,
"&"
)
# Then the < - More difficult!
rectext
=
rectext
.
replace
(
"<"
,
"<"
)
rectext
=
rectext
.
replace
(
"<record"
,
"<record"
)
rectext
=
rectext
.
replace
(
"</record"
,
"</record"
)
rectext
=
rectext
.
replace
(
"<datafield"
,
"<datafield"
)
rectext
=
rectext
.
replace
(
"</datafield"
,
"</datafield"
)
rectext
=
rectext
.
replace
(
"<controlfield"
,
"<controlfield"
)
rectext
=
rectext
.
replace
(
"</controlfield"
,
"</controlfield"
)
rectext
=
rectext
.
replace
(
"<subfield"
,
"<subfield"
)
rectext
=
rectext
.
replace
(
"</subfield"
,
"</subfield"
)
# Save the record back
fp
=
open
(
"
%s
/recmysql"
%
curdir
,
"w"
)
fp
.
write
(
rectext
)
fp
.
close
()
return
""
Event Timeline
Log In to Comment