def setUp(self): self.manifest = Manifest({ '': Manifest({ '': Manifest({ '': Program(name='root'), 'deep': Program(name="deep") }), }), 'sub': { 'prog': Program(name="prog"), 'another': { '': blank, 'prog2': Program(name='prog2'), 'prog3': Program(name='prog3'), 'http_only': Program(name='http_only', controllers=['http-get']), 'irc_only': Program(name='irc_only', controllers=['irc']), 'both': both }, 'double': [double_get, double_post] }, 'string_redirect': '/redirect', 'redirect': Program(name='redirect'), }) self.all_urls = set([ '/', '/deep', '/sub/another/irc_only', '/sub/another/http_only', '/sub/another/both', '/sub/prog', '/sub/another', '/sub/another/prog2', '/sub/another/prog3', '/redirect', '/string_redirect', '/sub/double' ]) self.irc_only_urls = set(['/sub/another/irc_only']) self.http_only_urls = set(['/sub/another/http_only', '/sub/double'])
def setUp(self): initialize() self.manifest = Manifest({ '': Program(model=[none], view=BasicView()), 'named': Program(model=[defaults], view=BasicView()), "another": { '': Program(name='another root'), 'name': Program(name='another name', view=BasicView()) } })
def setUp(self): initialize() self.manifest = Manifest({ 'no_defaults': Program(model=[no_defaults], view=BasicView()), 'defaults': Program(model=[defaults], view=BasicView()), 'primitives': Program(model=[primitive], view=BasicView()), 'raw': Program(model=[raw], view=BasicView()), 'none': Program(model=[none], view=BasicView), 'order': Program(model=[order], view=BasicView) })
from giotto.programs import Program, Manifest from giotto.programs.management import management_manifest from giotto.views import BasicView manifest = Manifest({ '': Program( model=[lambda: "Welcome to Giotto!"], view=BasicView ), 'mgt': management_manifest, })
def create_auth_manifest(**kwargs): """ Creates a basic authentication manifest for logging in, logging out and registering new accounts. """ class AuthProgram(Program): pre_input_middleware = [AuthenticationMiddleware] def register(username, password, password2): """ Decorated version of basic_register with a callback added. """ result = basic_register(username, password, password2) callback = kwargs.get('post_register_callback', None) if callback: user = User.objects.get(username=username) callback(user) return result return Manifest({ 'login': [ AuthProgram( """ Prints out the HTML form for logging in. """, name="Login (form)", input_middleware=[NotAuthenticatedOrRedirect('/')], view=BasicView( html=jinja_template('login.html'), ), ), AuthProgram( """ Matches up the username/password against the database, and adds the auth cookies. """, name="Login (post)", input_middleware=[NotAuthenticatedOrDie], controllers=['http-post', 'cmd'], model=[create_session, {'username': '******', 'session_key': 'XXXXXXXXXXXXXXX'}], view=BasicView( persist=lambda m: {'giotto_session': m['session_key']}, html=lambda m: Redirection('/'), ), ), ], 'logout': AuthProgram( """ Send the user here to log them out. Removes their cookies and deletes the auth session. """, name="Logout", view=BasicView( html=Redirection('/'), ), output_middleware=[LogoutMiddleware], ), 'register': [ AuthProgram( """ This program returns the HTML page with the form for registering a new account. HTTP-get only. """, name="Register (form)", input_middleware=[NotAuthenticatedOrRedirect('/')], view=BasicView( html=jinja_template('register.html'), ), ), AuthProgram( """ When you POST the register form, this program handles creating the new user, then redirecting you to '/' """, name="Register (post)", controllers=['http-post'], model=[register], view=BasicView( persist=lambda m: {'giotto_session': m['session_key']}, html=lambda m: Redirection('/'), ), ), ], })
from giotto.contrib.static.programs import StaticServe from giotto.programs import Program, Manifest from giotto.programs.management import management_manifest from giotto.views import BasicView, jinja_template from models import show_listings, CrawlResult, stats manifest = Manifest({ '': '/stats', 'stats': Program(model=[stats], view=BasicView(html=jinja_template('landing.html'))), 'api_docs': Program(view=BasicView(html=jinja_template('api.html'))), 'listings': Program(model=[show_listings], view=BasicView(html=jinja_template("show_listings.html"))), 'crawl': Program( controllers=['cmd'], model=[CrawlResult.do_crawl], ), 'static': StaticServe('/static'), 'mgt': management_manifest, })
from giotto.programs import Program, Manifest from giotto.programs.shell import shell from giotto.programs.tables import syncdb, flush from giotto.views import BasicView management_manifest = Manifest({ 'syncdb': Program(name="Make Tables", controllers=['cmd'], model=[syncdb], view=BasicView()), 'flush': Program( name="Blast Tables", controllers=['cmd'], model=[flush], view=BasicView(), ), 'shell': Program( name="Giotto Shell", controllers=['cmd'], model=[shell], view=BasicView(), ), })