Commits

Simone Marzola  committed c8f9de4

ops

  • Participants
  • Parent commits 639b265

Comments (0)

Files changed (5)

File .hgtags

-0c919c42d9cfa1cba0dbf6dacdcdc7faa7619ae6 0.4
-197839d00240a537984436540d2fd804075cee24 0.4.1
-050f9202f3f697eccbc8977f880f5c4d167b62e1 0.4.2
-application: gartichoke
+application: gartichoke-test
 version: 1
 runtime: python27
 api_version: 1
   static_dir: static/css
 
 - url: /images
-  static_dir: static/css
+  static_dir: static/images
 
 - url: /javascripts
   static_dir: static/javascripts

File example/test.py

-import artichoke, os, mimetypes, base64
-from artichoke import request, response, expose, url, redirect, flash
-from artichoke import FormBuilder
-
-class SubController(artichoke.Controller):
-    @expose()
-    def about(self, args, params):
-        return 'HELLO %s' % str(args)
-
-    @expose()
-    def index(self, args, params):
-        return 'INDEX'
-
-    @expose()
-    def not_found(self, args, params):
-        return 'Sub Not Found'
-
-class RootController(artichoke.Controller):
-    def __init__(self, application, templates_path, helpers):
-        super(RootController, self).__init__(application, templates_path, helpers)
-        self.sub = SubController(application, os.path.join(templates_path, 'sub'), helpers)
-
-    @expose('index')
-    def index(self, args, params):
-        return dict(foo=False, form=FormBuilder('/echo_image', {'image':{'type':'file'}}))
-
-    @expose()
-    def echo_image(self, args, params):
-        if params.has_key('image'):
-            image = params['image']
-            value = "data:%s;base64," % (mimetypes.guess_type(image.filename)[0] or "application/octet-stream")
-            value += base64.b64encode(image.file.read())
-        else:
-            value = ''
-
-        s = '''<html>
-<head>
-</head>
-<body>
-    <img src="%s"/>
-</body>
-</html>''' % value
-        return s
-
-    @expose('index')
-    def other(self, args, params):
-        foo = params.get('foo', False)
-        flash('Flash here!')
-        return dict(foo=foo)
-
-    @expose()
-    def crash(self, args, params):
-        raise Exception('FATAL')
-
-    def hidden(self, args, params):
-        return 'HIDDEN'
-
-    @expose()
-    def login(self, args, params):
-        class FakeUser(object):
-            pass
-
-        user = FakeUser()
-        user.user_name = params['user']
-        user.password = params['password']
-
-        response.identity = {'user':user}
-        flash('Welcome back!')
-        return redirect('/index')
-
-    @expose()
-    def logout(self, args, params):
-        response.identity = None
-        return redirect('/index')
-
-
-app = artichoke.Application(root=RootController, templates_path='views')
-
-if __name__ == '__main__':
-    from artichoke.server import serve
-    serve(app)

File example/views/index.choke

-<html lang="en">
-  <head>
-    <title>Hello</title>
-  </head>
-
-  <body>
-
-    ${%if response.flash_obj:}
-        <div>
-            <div class="${response.flash_obj['class']}">${response.flash_obj['msg']}</div>
-        </div>
-    ${%end}
-
-    <a href="${a.url('/other', dict(foo='foo'))}">${a.url('/other', dict(foo='foo'))}</a>
-
-    ${%if foo:}
-        <div>
-            <p>
-                Foo
-                ${%if request.identity:}
-                    <span>${request.identity['user'].user_name}</span>
-                ${%end}
-            </p>
-        </div>
-    ${%end}
-    ${%if not foo:}
-        <div>
-            <p>
-                Bar
-                ${%if request.identity:}
-                    <span>${request.identity['user'].user_name}</span>
-                ${%end}
-            </p>
-        </div>
-    ${%end}
-
-    ${%if defined('form'):}
-        <div>
-            <span>Upload an image, it will be shown back to you.<br/>
-            This only works with browsers that support HTML5 as the image won't be save on disk</span>
-            ${literal(form.render())}
-        </div>
-    ${%end}
-  </body>
-</html>

File setup.py

-from setuptools import setup, find_packages
-import sys, os
-
-version = '0.4.2'
-
-setup(name='artichoke',
-      version=version,
-      description="Simple and Lightweight WSGI Web Framework",
-      long_description="""\
-Artichoke is a lightweight WSGI Python framework for rapid prototyping of web applications. Artichoke has been developed with a syntax similar to the one of the Turbogears2 framework to permit to develop fast and small web applications which can be quickly switched to a full stack framework when necessary.
-""",
-      classifiers=["Development Status :: 5 - Production/Stable",
-                   "License :: OSI Approved :: GNU General Public License (GPL)",
-                   "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware",
-                   "Programming Language :: Python",
-                   "Topic :: Internet :: WWW/HTTP :: WSGI",
-                   "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
-                   "Topic :: Software Development :: Libraries :: Application Frameworks",
-                   "Environment :: Web Environment"],
-      keywords='wsgi web simple light',
-      author='AXANT',
-      author_email='tech@axant.it',
-      url='http://www.axantlabs.com/artichoke',
-      license='GPL',
-      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
-      include_package_data=True,
-      zip_safe=False,
-      install_requires=[
-          'webob',
-      ],
-      entry_points="""
-      # -*- Entry points: -*-
-      """,
-      )