python


Eve framework: on_update hook


I'm using Eve framework for REST API service.
Also I'm using DB hooks for doing some preprocessing before some actions:
http://python-eve.org/features.html#database-event-hooks
My question is:
Do I need to save into database my updated data in on_update hook or it's enough to update original item with updates like:
original.update(updates)
or it's needed to save this data somehow like this:
updated_item = original.update(updates)
# Fetch somehow requested resource from `resource_name` and do staff like this:
updated_resource = RequestedResource(updated_item)
updated_resource.commit()
Or there is some better/more EVE way?
Btw, I'm doing requests:
requests.patch("http://127.0.0.1:7000/users/2", headers=headers, json={"name": "John", "age": 30})
In your on_update hook, you just need to add/change the data you want changed on the updates dict received as parameter. It will already include the PATCH request body at this time and this is what will be sent to the update.
The original resource contains the resource being update and can be used for reference, but there's no use to change it.

Related Links

Difference between linear regression in Python (and R) and Stata
Default value of Django's model doesn't appear in SQL
Errno 2 - No such file or directory
Emails generated in loop not sending subject
OpenCV - Create multichannel Mat from numpy array
Python urlencode don't encode special characters
Making a sequence of tuples unique by a specific element
Can we make many views.py in Django as a Controller?
What is the status of Functional Reactive Programming in Python?
How to send a request by a private protocol with Python
Django+MongoDb connection error
Odoo/OpenERP failed mail handling
Makefile cannot find module in Python3
How to set up an article input function based on forms in Django
Insert nested value in mongodb using python
Error when installing using pip

Categories

HOME
dotnetrdf
oauth
formal-verification
travis-ci
matplotlib
apple-numbers
tizen-wearable-sdk
docker-windows
openwrt
facebook-javascript-sdk
iso
google-shopping
uiscrollview
sendkeys
rhapsody
factor-analysis
off-canvas-menu
ms-access-2007
google-api-java-client
kadanes-algorithm
excel-2010
cocoa-touch
source-maps
fabric
croppic
pipelinedb
visual-c++-2017
onesignal
unpack
pentaho-report-designer
getjson
m2e
getline
salesforce-chatter
ios-ui-automation
viewstate
boilerplate
mmdrawercontroller
office365connectors
initializer
twiki
nashorn
jrules
ttcn
bids
w3-total-cache
timesten
appstore-approval
mcrypt
pagefile
launch
iphone-developer-program
pdfkit
settimeout
sql-server-administration
coremidi
update-site
software-product-lines
json-schema-validator
unsatisfiedlinkerror
proxygen
p-np
twitter-rest-api
bridge
adobe-indesign
shift-jis
jazz
hiera
pl-i
android-search
and-operator
ghostdoc
httpcontext
voldemort
dvcs
help-viewer
internal
sqljdbc
process-monitor
returnurl
static-variables
cadisplaylink
scrollto
userid
concurrent-programming
ubuntu-11.04
tcxgrid
datamember
newsstand-kit
integer-promotion
act
longjmp
inline-if

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App