Skip to content

Commit

Permalink
needs to be in top level not in egg
Browse files Browse the repository at this point in the history
  • Loading branch information
alan runyan committed Oct 10, 2011
1 parent 1258cef commit f3ca62b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions start2.py
@@ -0,0 +1,41 @@
""" This is an example of running Ptah in 1 module. """

import cgi
from paste.httpserver import serve
from memphis import view
import ptah
import ptah_cms

view.registerRoute('show_models', '/show_models')

@view.pyramidView(route='show_models')
def show_models(request):
from ptah_cms import Session, Content
models = Session.query(Content).all()
return cgi.escape(str(models))

@view.pyramidView('show_info', context=ptah_cms.Content)
def show_info(context, request):
return cgi.escape(str(context.info()))

@view.pyramidView('list_children', context=ptah_cms.Container)
def list_children(context, request):
out = []
for name, child in context.items():
if isinstance(child, ptah_cms.Container):
href = '<a href="%slist_children">%s</a>' #XXX extra /?
href = href % (request.resource_url(child), child.title)
else:
href = '<a href="%sshow_info">%s</a>'
href = href % (request.resource_url(child), child.title)
out.append(href)
return '<br />'.join(out)

if __name__ == '__main__':
""" need to point to your settings.ini file in make_wsgi_app call.
http://localhost:8080/show_models is url dispatch function.
http://localhost:8080/list_children is traverser on context
$resource_url/show_info on either folder or content.
"""
app = ptah.make_wsgi_app({'settings':r'./ptah.ini'})
serve(app, host='0.0.0.0')

0 comments on commit f3ca62b

Please sign in to comment.