Exemple #1
0
class DummyRiak(object):
    def __init__(self):
        self.buckets = {}

    def bucket(self, name):
        bucket = self.buckets.setdefault(name, DummyRiakBucket())
        return bucket


riak = DummyRiak()

app = Groundhog(__name__,
                'seekr1t',
                authn_policy=authn_policy,
                authz_policy=authz_policy,
                riak_host='localhost',
                riak_port='8881',
                solr_url='http://my_solr_url')


@app.route('/entries/{slug}', methods='DELETE', permission='delete')
def entry_delete(slug):
    bucket = riak.bucket("entries")
    obj = bucket.new(slug)
    obj.delete()
    return HTTPNoContent()


@app.route('/entries/{slug}',
           methods='PUT',
Exemple #2
0
from groundhog import httpexceptions
from groundhog import Groundhog
from groundhog import request
from groundhog import application
from groundhog import g

# application

app = Groundhog(__name__, 'seekrit')


@app.route('/')
def root():
    return 'root'


@app.route('/miss')
def miss():
    raise httpexceptions.HTTPNotFound()


@app.route('/redirect')
def redirect():
    app.redirect('/')


@app.route('/abort500')
def abort500():
    app.abort(500, 'its broke')

Exemple #3
0
class DummyRiak(object):
    def __init__(self):
        self.buckets = {}

    def bucket(self, name):
        bucket = self.buckets.setdefault(name, DummyRiakBucket())
        return bucket

riak = DummyRiak()

app = Groundhog(
    __name__,
    'seekr1t',
    authn_policy=authn_policy,
    authz_policy=authz_policy,
    riak_host='localhost',
    riak_port='8881',
    solr_url='http://my_solr_url'
    )

@app.route('/entries/{slug}', methods='DELETE', permission='delete')
def entry_delete(slug):
    bucket = riak.bucket("entries")
    obj = bucket.new(slug)
    obj.delete()
    return HTTPNoContent()

@app.route('/entries/{slug}', methods='PUT', accept='application/json',
           permission='update')
def entry_update(slug):
Exemple #4
0
from groundhog import httpexceptions
from groundhog import Groundhog
from groundhog import request
from groundhog import application
from groundhog import g

# application

app = Groundhog(__name__, 'seekrit')

@app.route('/')
def root():
    return 'root'

@app.route('/miss')
def miss():
    raise httpexceptions.HTTPNotFound()

@app.route('/redirect')
def redirect():
    app.redirect('/')

@app.route('/abort500')
def abort500():
    app.abort(500, 'its broke')

@app.route('/showrequest')
def showrequest():
    import cgi
    print request
    print application
Exemple #5
0
from groundhog import Groundhog
from repoze.profile.profiler import AccumulatingProfileMiddleware
from paste.httpserver import serve

# application

app = Groundhog(__name__, 'seekrit')

@app.route('/')
def root():
    return 'hello'

if __name__ == '__main__':
    wsgiapp = app.get_wsgiapp()
    wrapped = AccumulatingProfileMiddleware(wsgiapp)
    serve(wrapped)