GithubHelp home page GithubHelp logo

Comments (5)

amalashkevich avatar amalashkevich commented on August 28, 2024

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.

xmonader avatar xmonader commented on August 28, 2024

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.

kozlovsky avatar kozlovsky commented on August 28, 2024

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.

xmonader avatar xmonader commented on August 28, 2024

@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.

amalashkevich avatar amalashkevich commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.