Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F76481755
bibrecord_manager.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, Aug 8, 05:25
Size
1 KB
Mime Type
text/x-python
Expires
Sat, Aug 10, 05:25 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19719446
Attached To
R3600 invenio-infoscience
bibrecord_manager.py
View Options
# -*- coding: utf-8 -*-
##
## This file is part of Invenio.
## Copyright (C) 2013 CERN.
##
## 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.
##
## 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 Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
from
invenio.scriptutils
import
Manager
manager
=
Manager
(
usage
=
"Perform BibRecord operations"
)
# Define sub-manager
bibrecord_cache
=
Manager
(
usage
=
"Manipulates BibRecord cache."
)
# Add sub-manager
manager
.
add_command
(
"cache"
,
bibrecord_cache
)
@bibrecord_cache.command
def
reset
(
split_by
=
1000
):
"""Reset bibrecord structure cache."""
from
invenio.bibedit_model
import
Bibfmt
from
invenio.cache_manager
import
reset_rec_cache
from
invenio.dbquery
import
run_sql
,
serialize_via_marshal
from
invenio.search_engine
import
get_record
from
invenio.sqlalchemyutils
import
db
def
get_recstruct_record
(
recid
):
value
=
serialize_via_marshal
(
get_record
(
recid
))
b
=
Bibfmt
(
id_bibrec
=
recid
,
format
=
'recstruct'
,
last_updated
=
db
.
func
.
now
(),
value
=
value
)
db
.
session
.
add
(
b
)
db
.
session
.
commit
()
reset_rec_cache
(
'recstruct'
,
get_recstruct_record
,
split_by
=
split_by
)
def
main
():
from
invenio.webinterface_handler_flask
import
create_invenio_flask_app
app
=
create_invenio_flask_app
()
manager
.
app
=
app
manager
.
run
()
if
__name__
==
'__main__'
:
main
()
Event Timeline
Log In to Comment