Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91135950
bibcatalog_system.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
Fri, Nov 8, 06:51
Size
6 KB
Mime Type
text/x-python
Expires
Sun, Nov 10, 06:51 (2 d)
Engine
blob
Format
Raw Data
Handle
22198275
Attached To
R3600 invenio-infoscience
bibcatalog_system.py
View Options
# -*- coding: utf-8 -*-
##
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 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.
"""
Provide a "ticket" interface with a request tracker.
Please see the help/hacking/bibcatalog-api page for details.
This is a base class that cannot be instantiated.
"""
from
invenio.webuser
import
get_user_preferences
class
BibCatalogSystem
:
""" A template class for ticket support."""
TICKET_ATTRIBUTES
=
[
'ticketid'
,
'priority'
,
'recordid'
,
'subject'
,
'text'
,
'creator'
,
'owner'
,
'date'
,
'status'
,
'queue'
,
'url_display'
,
'url_modify'
,
'url_close'
]
def
check_system
(
self
,
uid
):
"""Check connectivity. Return a string describing the error or an empty str
@param uid: invenio user id
@type uid: number
@return: empty string on success. Otherwise a string describing error.
@rtype: string
"""
return
"this class cannot be instantiated"
def
ticket_search
(
self
,
uid
,
recordid
=-
1
,
subject
=
""
,
text
=
""
,
creator
=
""
,
owner
=
""
,
\
date_from
=
""
,
date_until
=
""
,
status
=
""
,
priority
=
""
):
"""Search for tickets based on various criteria. Return an array of ticket numbers
@param uid: invenio user id.
@type uid: number
@param recordid: search criteria - ticket contains this record id.
@type recordid: number
@param subject: search criteria - ticket has this subject (substr).
@type subject: string
@param text: search criteria - ticket has this text in body (substr).
@type text: string
@param creator: search criteria - ticket creator's id.
@type creator: number
@param owner: search criteria - ticket owner's id.
@type owner: number
@param date_from: search criteria - ticket created starting from this date. Example: '2009-01-24'
@type date_until: date in yyyy-mm-dd format
@param date_until: search criteria - ticket created until from this date. Example: '2009-01-24'
@type date_from: date in yyyy-mm-dd format
@param status: search criteria - ticket has this status. Example: 'resolved'.
@type status: string
@param priority: search criteria - ticket priority number.
@type priority: number.
"""
pass
def
ticket_submit
(
self
,
uid
,
subject
,
recordid
,
text
=
""
,
queue
=
""
,
priority
=
""
,
owner
=
""
):
"""submit a ticket. Return ticket number on success, otherwise None
@param uid: invenio user id
@type uid: number
@param subject: set this as the ticket's subject.
@type subject: string
@param recordid: ticket concerns this record.
@type recordid: number
@param text: ticket body.
@type text: string
@param queue: the queue for this ticket (if supported).
@type queue: string
@param priority: ticket priority.
@type priority: number
@param owner: set ticket owner to this uid.
@type owner: number
@return: new ticket id or None
"""
pass
def
ticket_assign
(
self
,
uid
,
ticketid
,
to_user
):
"""assign a ticket to a user. Return 1 on success
@param uid: invenio user id
@type uid: number
@param ticketid: ticket id
@type ticketid: number
@param to_user: assign ticket to this user
@type to_user: number
@return: 1 on success, 0 otherwise
@rtype: number
"""
pass
def
ticket_set_attribute
(
self
,
uid
,
ticketid
,
attribute
,
new_value
):
"""set an attribute of a ticket. Return 1 on success
@param uid: invenio user id
@type uid: number
@param ticketid: ticket id
@type ticketid: number
@param attribute. This is a member of TICKET_ATTRIBUTES.
@type attribute: string
@param new_value: new value for this attribute.
@type new_value: string
@return: 1 on success, 0 otherwise
@rtype: number
"""
pass
def
ticket_get_attribute
(
self
,
uid
,
ticketid
,
attrname
):
"""return an attribute
@param uid: invenio user id
@type uid: number
@param ticketid: ticket id
@type ticketid: number
@param attrname: attribute name.
@type attrname: string
@return: the value of the attribute, or None if the ticket or attribute does not exist
@rtype: string
"""
pass
def
ticket_get_info
(
self
,
uid
,
ticketid
,
attrlist
=
None
):
"""Return the attributes of a ticket as a dictionary whose fields are TICKET_ATTRIBUTES.
@param uid: user id
@type uid: number
@param ticketid: ticket id
@type ticketid: number
@param attrlist: a list of attributes, each in TICKET_ATTRIBUTES.
@type attrlist: list
@return: dictionary whose fields are TICKET_ATTRIBUTES
@rtype: dictionary
"""
pass
def
get_bibcat_from_prefs
(
uid
):
"""gets username and pw from user prefs as a tuple.
if not successfull, returns None
@param uid: user id
@type uid: number
@return: ('bibcatalog_username', 'bibcatalog_password')
@rtype: tuple
"""
user_pref
=
get_user_preferences
(
uid
)
if
not
user_pref
.
has_key
(
'bibcatalog_username'
):
return
(
None
,
None
)
if
not
user_pref
.
has_key
(
'bibcatalog_password'
):
return
(
None
,
None
)
return
(
user_pref
[
'bibcatalog_username'
],
user_pref
[
'bibcatalog_password'
])
Event Timeline
Log In to Comment