Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab has been updated. More info
here
.
Show more breadcrumbs
w2pext
plugin_dbui
Commits
b1c2eb47
Commit
b1c2eb47
authored
16 years ago
by
Renaud Le Gac
Browse files
Options
Downloads
Patches
Plain Diff
First version of the service delete.
parent
437089d6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/services.py
+29
-2
29 additions, 2 deletions
modules/services.py
with
29 additions
and
2 deletions
modules/services.py
+
29
−
2
View file @
b1c2eb47
...
...
@@ -16,11 +16,13 @@ __version__ = "$Revision"
import
re
from
gluon.contrib
import
simplejson
as
json
#from tools import debug
import
sqlite3
RECORD_IS_DELETED
=
"
Record id %i deleted
"
FIELD_BAD_SYNTAX
=
"
The syntax of the request field %s is wrong: db.table.field
"
FIELD_BAD_TABLE
=
"
Table defined in the request field %s doesn
'
t exist.
"
FIELD_BAD_FIELD
=
"
Field defined in the request field %s doesn
'
t exist.
"
ID_MISSING
=
"
The keyword id is not defined.
"
INSERT_SUCCESSFUL
=
"
Data insert successfully.
"
SVC_INVALID
=
"
Requested service doesn
'
t exist.
"
SVC_NOT_DEFINED
=
"
The keyword service is not defined.
"
...
...
@@ -168,11 +170,36 @@ class HttpDb:
def
delete
(
self
):
"""
Delete data in the database.
Delete a record identified by its id.
Mandatory steering keywords are: service, table and id.
Return a dictionary with status and error message:
{success: False, msg:
'
blalbla
'
}
"""
return
{
"
success
"
:
False
,
"
msg
"
:
SVC_NOT_IMPLEMENTED
}
if
self
.
_debug
():
print
"
Start HttpDb.debug service.
"
# Check table
if
"
table
"
not
in
self
.
_vars
:
resp
=
{
"
success
"
:
False
,
"
msg
"
:
TABLE_MISSING
}
return
resp
# Check id
if
"
id
"
not
in
self
.
_vars
:
resp
=
{
"
success
"
:
False
,
"
msg
"
:
ID_MISSING
}
return
resp
# Delete the record
id
=
int
(
self
.
_vars
.
id
)
table
=
self
.
_vars
.
table
try
:
del
self
.
_db
[
table
][
id
]
except
sqlite3
.
Error
,
e
:
return
{
"
success
"
:
False
,
"
msg
"
:
e
.
message
}
return
{
"
success
"
:
True
,
"
msg
"
:
RECORD_IS_DELETED
%
id
}
def
get_defaults
(
self
):
pass
def
get_fields
(
self
):
pass
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment