Commit 2fc47465 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add error detection in the controller publications/update.

Bug fixed in epydoc strings.
parent 1f991b65
......@@ -2,20 +2,17 @@
"""
import json
import plugin_dbui
def read():
"""Read a publication record identified by its id.
Design to load a record within a basic Ext.formPanel.
Design to load a record within a basic Ext.form.Panel.
"""
id = request.vars.id
row = db.publications[id]
rep = dict(success=True,
data=row.as_dict())
return json.dumps(rep)
return json.dumps(dict(success=True, data=row.as_dict()))
def update():
......@@ -26,10 +23,21 @@ def update():
"""
id = request.vars.id
del request.vars.id
table = db.publications
db.publications[id] = request.vars
rep = dict(success=True,
msg="Record %s modified" % id)
# update the record
try:
rep = db(table.id==id).update(**request.vars)
# operation can be rejected by the database
except Exception as dbe:
return json.dumps(dict(success=False, msg=dbe.message))
# operation can be reject by callbacks table._before_update
if not rep:
msg = "Reject by a callback"
if plugin_dbui.CALLBACK_ERRORS in table:
return json.dumps(dict(success=False, msg=table._callback_errors))
return json.dumps(rep)
\ No newline at end of file
return json.dumps(dict(success=True, msg="Record %s modified" % id))
\ No newline at end of file
......@@ -467,7 +467,6 @@ class Msg(Storage):
class MsgCollection(Storage):
"""Message for a collection. The class contains five public attributes:
- C{error}: error when scanning the collection
- C{found}: number of publication found in the harvester repository
- C{url}: URL used to scan the harvester repository, returning a list ids.
......@@ -907,12 +906,12 @@ class PublicationsTool(object):
@rtype: dict
@return:
- C(cfg_statStore) (str) configuration of the statStore JSON encoded
- C(cfg_logsStore) (str) configuration of the logsStore JSON encoded
- C{collection_logs) (list) one L{MsgCollection}) for each collection
- C{cfg_statStore} (str) configuration of the statStore JSON encoded
- C{cfg_logsStore} (str) configuration of the logsStore JSON encoded
- C{collection_logs} (list) one L{MsgCollection}) for each collection
- C{harvester} (Storage)
- C{logs) (list) one L{Msg} for each publication
- C{selector} (Selecor)
- C{logs} (list) one L{Msg} for each publication
- C{selector} (Selector)
"""
......
......@@ -9,6 +9,7 @@ HEAD
- Redesign the harvester/check_validate views using inline javascript.
- Redesing the harvester/check_validate views returning LaTex document.
- Add the wizard compare_publications.
- Add the possibility to modify a record from the check_validate view.
0.8.5 (May 2014)
- Migrate to plugin_dbui 0.6.1.1 and web2py 2.9.5
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment