Hi All,

I created a simple tutorial how to integrate repoze.tm2 with storm in pylons.
You can read it at: https://storm.canonical.com/PylonsRepoze.tm2

It does not require the StormMiddleware app anymore.

Cheers,
 -Olaf

2008/7/28 Tres Seaver <[EMAIL PROTECTED]>
>
> FYI.
>
> - -------- Original Message --------
> Subject: [storm] RFC: Storm with Pylons and Repoze.tm2
> Date: Sun, 27 Jul 2008 18:29:19 +0200
> From: Olaf Conradi <olaf at conradi.org>
> To: storm at lists.canonical.com
>
> Hello,
>
> I modified the Zope module for Storm to use repoze.tm2 as transactions
> and add a middleware layer for use with Pylons.
>
> Let's describe it with a Pylons example:
>
> In development.ini:
>
> # Add repoze.tm2 in the pipeline
> [pipeline:main]
> pipeline = egg:Paste#cgitb
>           egg:Paste#httpexceptions
>           egg:repoze.tm2#tm
>           your-app
>
> In middleware.py:
>
> # add import
> from storm.tm.middleware import StormMiddleware
>
> # inside make_app(global_conf, full_stack=True, **app_conf):
>
>    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
>    app = StormMiddleware(app)
>
> In the controller of your app:
>
> # add import
> from storm.store import Store
> from storm.tm.session import storm_session
>
> from yourapp.model import Person
>
> class MyController(BaseController):
>    def index(self):
>        store = storm_session.get('persondb',
> config['storm.database.persons.uri'])
>        c.persons = list(store.find(Person))
>        return render('list.mako')
>
> Just like the zope module had global_zstorm, this module uses
> storm_session for use in your Pylons application. It's now a
> StackedObjectProxy, and I think I can therefore remove the thread
> local stuff from TMStorm.
>
> A lot of code is the same between the Zope module and this module. It
> would be nice to share that, and not duplicate it.
>
> Because of repoze.tm2 each request will be a transaction, it will
> abort on 401 or raised exceptions, or otherwise commit.
>
> An example of a controller which adds a records:
>
>    def new(self):
>        store = storm_session.get('persondb',
> config['storm.database.persons.uri'])
>        p = Person()
>        p.firstname = u"Boo"
>        p.lastname = u"Foo"
>        p.gender = "Male"
>        p.date_of_birth = date(1975, 2, 8)
>        store.add(p)
>        return 'Done'
>
> So no need to use store.commit, it will be handled by repoze.tm2.
> If you add a second store both will either commit or rollback.
>
> The code is hosted in a launchpad branch, use:
> bzr branch lp:~olaf-conradi/storm/tmstorm
>
> Comments are welcome ;)
>
> Cheers,
> -Olaf
>
> - --
> storm mailing list
> storm at lists.canonical.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/storm
>
> - --
> ===================================================================
> Tres Seaver          +1 540-429-0999          tseaver at palladion.com
> Palladion Software   "Excellence by Design"    http://palladion.com
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to