« Return to Thread: Newbie Question

Re: Newbie Question

by lists-144 :: Rate this Message:

Reply to Author | View in Thread

Hi Anthony,

see below for a standalone dev server (not tested though) using WSGI. For more information on using Pylons with PyAMF check the tutorial:
http://pyamf.org/wiki/PylonsHowto

hth,

Thijs

import os
from wsgiref import simple_server

from pyamf.remoting.gateway.wsgi import WSGIGateway

import psycopg2

def fetch(data):
    cur.execute("""SELECT datname from pg_database""")
    rows = cur.fetchall()
    ret = []

    

    print "Show me the rows:"
    for row in rows:
        print "   ", row[0]
        ret.append(row[0])

        

    return ret

services = {
    'fetch': fetch
}

if __name__ == '__main__':

    try:
       conn = psycopg2.connect("dbname='template1' user='dbuser' host='localhost' password='dbpass'")
       cur = conn.cursor()
    except:
       print "Unable to connect to the database"

    

    gw = WSGIGateway(services)

    httpd = simple_server.WSGIServer(
        ('localhost', 8000),
        simple_server.WSGIRequestHandler,
    )

    httpd.set_app(gw)

    print "Running psycopg2 AMF gateway on http://localhost:8000"

    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass

On 27 May 2009, at 16:55, Anthony Caduto wrote:

Hi,
Just found out about pyamf and it looks like the way to go with flex.

I want to use Pylons as my remoting gateway but I am stuck on how to get data from PostgreSQL
back to flex to use in the datagrid.

I am using /Psycopg2 via the python dbi interface and do not want to use sql alchemy.

If anyone has any suggestions on how to accomplish this please let me know.

Thanks,

Tony
/

_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users



_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users

PGP.sig (201 bytes) Download Attachment

 « Return to Thread: Newbie Question