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

Datalab: How to export Big Query standard SQL query to dataframe?
Pandas: count difference between dates
Skip one line in .csv file by using genfromtxt function in python
Dealing with NaNs in Pandas
Python Script? - Logging serial output from arduino
Iterate links from selenium into bs4 and print stripped strings
Query for only part of objects of related_name (from ForeignKey)
How to fill in missing sequence lines in a TSV file
Django website optimization: Too many calls to core python functions?
How to post issues to gitlab using python?
Coverage and nose shows files from django and not just my tests
Hexbin scatter plot between two 2D numpy arrays
How to assign a ForeignKey field when a new instance is created
Click a specific button and a checkbox using Selenium
Searching a directory for specific XML in Python
How can we take an input from user in python? as we take it in 'C' using scanf(); [duplicate]

Categories

HOME
swift
laravel-5
cil
checkbox
angular-cli
antivirus
vs-team-services
otrs
i2c
gimp
ndis
nuxt.js
phoenix
ssms-2016
redux-observable
plsqldeveloper
google-ima
spring-ws
skmaps
branch
helper
multichoiceitems
invoke-command
freebase
polymorphism
pljson
data-extraction
modulo
gettext
vsts-package-management
inkscape
strstr
wcf-security
ical-dotnet
nashorn
android-maps-v2
matlab-cvst
rich-text-editor
defold
tiddlywiki
windows-95
volume
fedora20
iphone-developer-program
svn-merge
gradle-script-kotlin
chessboard.js
uwp-maps
spring-lemon
codesign
axes
loose-typing
mysqldumpslow
gray-code
adodb
temp-tables
microblaze
vcl
aquafold
io.js
neoload
lumx
uipickerviewcontroller
svcutil.exe
angulartics
layered
stagefright
gridworld
dynamics-ax-2009
mvs
cgpath
osi
point-sprites
separation-of-concerns
ubuntu-11.04
selectonemenu
webkit-transform
serp
ruby-debug
adobe-contribute
drawtext
querypath
gwt-2.2-celltable
scala-2.8
aio
idictionary
pci-bus
lazy-c++

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