I saw this via google a bit ago. does the below not work with
sqlalchemy? (if im asking an obvious question i apologize as im just
getting started w/ pylons)

It seemed like a simpler setup... altho I am having issues getting the
logging working.

--nik

http://laiso.pastebin.com/gh9Z3SJ6

#!/usr/bin/env python
# coding: utf-8

from gevent import monkey; monkey.patch_all()
from gevent.wsgi import WSGIServer

import os
import logging
log = logging.getLogger(__name__)

from paste.deploy import loadapp


PORT = 8088

def main():
    config_path = os.path.join(os.path.abspath(os.path.curdir),
'development.ini')
    wsgi_app = loadapp('config:' + config_path)
    log.info('Serving on %d...' % PORT)
    WSGIServer(('', PORT), wsgi_app).serve_forever()

if __name__ == '__main__':
    main()




On Nov 19, 10:00 pm, askel <[email protected]> wrote:
> I forgot to mention that make_psycopg2_green has to be called
> somewhere like at the beginning of init_model call.
>
> And the fun part was that I was able to do something like the
> following:
>
> # myproject/lib/app_globals.py
> from gevent.event import Event
>
> class Globals(object):
>     def __init__(self, config):
>         self.messages = []
>         self.message_posted = Event()
>
> # myproject/controllers/chat.py
>
> class Chat(BaseController):
>
>     def post(self):
>         g.messages.append(request.params['message']
>         g.last_modified = timestamp()
>         # this is similar to Object.notifyAll() in Java
>         g.message_posted.set()
>         g.message_posted.clear()
>
>     def watch(self):
>         if g.last_modified < request.if_modified_since:
>             render('messages', g.messages)
>         if not g.message_posted.wait(timeout=I_AM_PRETTY_PATIENT):
>             abort(304, 'Not modified')
>         response.last_modified = g.last_modified
>
> The biggest thing about above code that I didn't have to worry about
> race conditions. Whatever current code does happens in single thread.
> No locking needed whatsoever! Isn't that what you were dreaming of in
> concurrent programming? Lock-less multi-threading. And there is more -
> no GIL overhead :)
>
> I guess this is not suitable for everything but this was another big
> thing that made me love Python, Pylons, SQLAlchemy, people who drive
> all that and people who love that.
>
> Peace,
> Alexander

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to