Ejemplo n.º 1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    import logging
    logging.basicConfig(level=logging.DEBUG)

    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()

    from pyramid_jinja2 import renderer_factory
    config.add_renderer('.jinja2', renderer_factory)

    # configure views, templates
    configure(config) 

    # configure session
    import pyramid_beaker
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # configure OpenID-specific storage
    import stucco_openid.models
    from openid.store import filestore
    stucco_openid.models.root.store = \
        filestore.FileOpenIDStore(settings['openid.store_file_path'])

    config.end()
    return config.make_wsgi_app()
Ejemplo n.º 2
0
def main(global_config, **settings):
    config = Configurator(settings=settings)

    # Maintenance
    config.add_route('blitz-io-verification',
                     '/mu-1e32b3b5-6f6be39c-4bc74834-6b7586e8')
    config.add_route('maintenance-200', '/maintenance/200')

    # Internal
    config.add_route('saasy-subscriptions', '/services/saasy/subscriptions')

    # API routing
    config = v_0_1_routing(config)
    config = v_0_2_routing(config)
    config.scan('tickee_api.resources')

    # OAuth 2 routing
    configure_oauth2_routing(config)
    config.scan('pyramid_oauth2.views')
    return config.make_wsgi_app()
Ejemplo n.º 3
0
 def _makeOne(self, *arg, **kw):
     from pyramid.configuration import Configurator
     return Configurator(*arg, **kw)
Ejemplo n.º 4
0
    try:
        form.validate(request)
    except formish.FormError, e:
        log.debug(e)
    except Exception, e:
        log.debug(e)

    return {'form':form, 'form2':form}

def goodbye_world(request):
    return Response('Goodbye world!')

class QuietHandler(simple_server.WSGIRequestHandler):
    def log_message(self, format, *args): pass

if __name__ == '__main__':
    import logging
    logging.basicConfig(level=logging.DEBUG)
    config = Configurator(settings={'reload_templates':True})
    config.begin()
    sm = zope.component.getSiteManager()
    sm.registerUtility([resource_filename('pyramid_uniform', 'templates/zpt')],
            pyramid_formish.IFormishSearchPath)
    config.add_static_view('static', 'pyramid_uniform:templates/static')
    config.add_view(sample_form, renderer="pyramid_uniform:templates/index.pt")
    config.end()
    app = config.make_wsgi_app()
    simple_server.make_server('', 9876, app, handler_class=QuietHandler).serve_forever()

Ejemplo n.º 5
0
import json as simplejson

from pyramid.configuration import Configurator
from paste.httpserver import serve

from beaker.cache import cache_regions, cache_region
cache_regions['short_term'] = dict(type='memory', expire=30*60)

def index(request):
    fml_endpoint = 'http://graph.facebook.com/search?q="so%20starving&type=post'
    
    @cache_region('short_term')   
    def fb_data(key=None):
        fb_response = urllib.urlopen(key,).read()
        return simplejson.loads(fb_response)["data"]
        
    return {'data': fb_data(fml_endpoint)}

settings = {}
settings['mako.directories'] = './templates'
config = Configurator(settings=settings)
config.begin()
config.add_view(index, name='', renderer='index.mako')
config.end()

application = config.make_wsgi_app()

if __name__ == '__main__':
    serve(application, host='0.0.0.0')