Comments (5)
Each function which works with Pony ORM should be wrapped with
@with_transaction decorator. This decorator automatically does commit (or
rollback in case of an exception happened inside the function), clears the
cache and returns the database connection to the connection pool.
If you use Flask you can wrap your application this way:
app.wsgi_app = with_transaction(app.wsgi_app)
In this case there is no need to wrap each function.
On Fri, May 3, 2013 at 2:46 AM, xmonader [email protected] wrote:
Hi, i'm working on application and apparently there as conflict between
the current data and the cached data. so is there away to force reacaching
on the new data available ?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/5
.
AM
from pony.
Thanks for the quick response, I'm using Bottle for this application.
Now i'm getting Obsolete cache (https://gist.github.com/xmonader/5506317)
This is how i modified the code with_transaction decorator
https://gist.github.com/xmonader/5506325
from pony.
You should apply @with_transaction decorator to most outer function which works with the database. When you use Bottle, this most outer function will be the WSGI application.
I think you should remove @with_transaction decorator off your create_link() function and instead add this line to your code, after all imports from Bottle and pony:
app().wsgi = with_transaction(app().wsgi)
I cannot check right now if this line is correct, but probably it is. If it doesn't work, I'll give correct answer tomorrow, when I'll be near my PC. If you will test this line earlier, please tell how it works
from pony.
@kozlovsky : Thanks for your help, this is how I managed it
app=default_app()
app.__name__="something"
app=with_transaction(app)
run(app=app,debug=True, port=7000,reloader=True)
without manually setting name to app, I'll get this error
Traceback (most recent call last):
File "app.py", line 101, in
app=with_transaction(default_app())
File "/home/striky/Envs/bottleurl/lib/python2.7/site-packages/pony/utils.py", line 41, in new_func
return old_dec(old_func, _args, *_kwargs)
File "/home/striky/Envs/bottleurl/lib/python2.7/site-packages/pony/utils.py", line 55, in decorator_with_params
return copy_func_attrs(new_func, old_func, old_dec.name)
File "/home/striky/Envs/bottleurl/lib/python2.7/site-packages/pony/utils.py", line 25, in copy_func_attrs
new_func.name = old_func.name
AttributeError: 'Bottle' object has no attribute 'name'
Thanks alot.
from pony.
We've just added the integration with Bottle. You can use PonyPlugin from pony/orm/integration/bottle_plugin.py module. Check the example here pony/orm/examples/bottle_example.py
from pony.
Related Issues (20)
- SQLite: JSON entity doesn't meet Python Standard HOT 1
- How to combine two `query.filter()` calls using `OR` operator? HOT 3
- pony.orm.decompiling.DecompileError: Unsupported operation: POP_JUMP_IF_NONE
- Python 3.12 support HOT 1
- test_json fails with sqlite 3.45 HOT 1
- can l use pony orm with flask admin library?
- Using sqlite extensions
- error constructing query from stored subqueries HOT 1
- Disabling automatic persistence
- Django Integration
- select - decompiling - errors HOT 1
- Column aliasing in PonyOrm's global select() function
- How to integrate with Dependency Injector lib
- Auto-complete on entity construction when using intellisense (VSCode) HOT 1
- Database property to check if mapping has been generated
- how to use pony orm in fastapi app&sync router,any demo code ?
- Better support for default schemas
- Support Views and Materialized Views
- date-type field not automatically converted from text to date when using SQLite (?)
- Python 3.12 not supported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pony.