[pypy-svn] r31646 - pypy/dist/pypy/translator/js/turbogears

ericvrp at codespeak.net ericvrp at codespeak.net
Fri Aug 25 17:16:51 CEST 2006


Author: ericvrp
Date: Fri Aug 25 17:16:46 2006
New Revision: 31646

Added:
   pypy/dist/pypy/translator/js/turbogears/
   pypy/dist/pypy/translator/js/turbogears/__init__.py   (contents, props changed)
   pypy/dist/pypy/translator/js/turbogears/setup.py   (contents, props changed)
   pypy/dist/pypy/translator/js/turbogears/templateplugin.py   (contents, props changed)
   pypy/dist/pypy/translator/js/turbogears/upload.sh   (contents, props changed)
Log:
Some WIP for nice TurboGears integration of PyPy-JS.
   * the setup script to create a Cheeseshop egg.
   * An upload shell script (will replace with Pythoncode later) because the egg is
     currently actually stored on codespeak. (because Cheeseshop allows only 5Mb per egg)
   * A TG plugin that will (hopefully) someday soon allow @expose(template="asjavascript")


Added: pypy/dist/pypy/translator/js/turbogears/__init__.py
==============================================================================

Added: pypy/dist/pypy/translator/js/turbogears/setup.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/turbogears/setup.py	Fri Aug 25 17:16:46 2006
@@ -0,0 +1,75 @@
+from setuptools import setup, find_packages
+from turbogears.finddata import find_package_data
+import os
+
+svninfo = os.popen('svn info rpython2javascript').read().split()
+version = int(svninfo[svninfo.index('Revision:') + 1])
+
+setup(
+    name="rpython2javascript",
+    version="0.%d" % version,
+    
+    description="RPython to JavaScript translator",
+    #description_long="""This is a derivative of the PyPy project. Some words about RPython can be found at http://codespeak.net/pypy/dist/pypy/doc/coding-guide.html#restricted-python""",
+    author="PyPy developers, Maciek Fijalkowski, Eric van Riet Paap",
+    author_email="pypy-dev at codespeak.net",
+    url="http://codespeak.net/pypy",
+    download_url="http://codespeak.net/~ericvrp/rpython2javascript/",
+    license="MIT",
+    
+    #install_requires = [
+    #    "TurboGears >= 1.1a0",
+    #],
+
+    #scripts = [
+    #    "start-topl.py"
+    #],
+
+    zip_safe=False,
+
+    packages=find_packages(),
+    package_data=find_package_data(
+                    where='rpython2javascript', package='rpython2javascript',
+                    only_in_packages=False, exclude=('*.pyc', '*~', '.*', '*.bak')),
+
+    entry_points="""
+        [python.templating.engines]
+        asjavascript = rpython2javascript.pypy.translator.js.turbogears.templateplugin:TemplatePlugin""",
+        
+    #keywords = [
+    #    # Use keywords if you'll be adding your package to the
+    #    # Python Cheeseshop
+    #    
+    #    # if this has widgets, uncomment the next line
+    #    # 'turbogears.widgets',
+    #    
+    #    # if this has a tg-admin command, uncomment the next line
+    #    # 'turbogears.command',
+    #    
+    #    # if this has identity providers, uncomment the next line
+    #    # 'turbogears.identity.provider',
+    #
+    #    # If this is a template plugin, uncomment the next line
+    #    # 'python.templating.engines',
+    #    
+    #    # If this is a full application, uncomment the next line
+    #    # 'turbogears.app',
+    #],
+
+    classifiers = [
+        'Development Status :: 3 - Alpha',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        #'Framework :: TurboGears',
+        # if this is an application that you'll distribute through
+        # the Cheeseshop, uncomment the next line
+        # 'Framework :: TurboGears :: Applications',
+        
+        # if this is a package that includes widgets that you'll distribute
+        # through the Cheeseshop, uncomment the next line
+        # 'Framework :: TurboGears :: Widgets',
+    ],
+    #test_suite = 'nose.collector',
+    )
+

Added: pypy/dist/pypy/translator/js/turbogears/templateplugin.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/turbogears/templateplugin.py	Fri Aug 25 17:16:46 2006
@@ -0,0 +1,53 @@
+import cherrypy
+from rpython2javascript import rpython2javascript
+
+class TemplatePlugin:
+
+    def __init__(self, extra_vars_func=None, options=None):
+        """The standard constructor takes an 'extra_vars_func',
+        which is a callable that is called for additional
+        variables with each rendering. Options is a dictionary
+        that provides options specific to template engines
+        (encoding, for example). The options should be
+        prefixed with the engine's scheme name to allow the
+        same dictionary to be passed in to multiple engines
+        without ill effects."""
+        pass
+    
+    # the template name will be in python "dot" notation
+    # eg "package1.package2.templatename". It will *not*
+    # have the extension on it. You may want to cache the
+    # template. This method is only called directly if a
+    # template is specified in turbogears.view.baseTemplates.
+    # You might call this yourself from render.
+    # This doesn't *have* to return anything, but
+    # existing implementations return a template class.
+    # (this does not necessarily make sense for all template
+    # engines, though, which is why no return value is
+    # required.)
+    def load_template(self, templatename):
+        "Find a template specified in python 'dot' notation."
+        pass
+    
+    # info is the dictionary returned by the user's controller.
+    # format may only make sense for template engines that can
+    # produce different styles of output based on the same
+    # template.
+    # fragment is used if there are special rules about rendering
+    # a part of a page (don't include headers and declarations).
+    # template is the name of the template to render.
+    # You should incorporate extra_vars_func() output
+    # into the namespace in your template if at all possible.
+    def render(self, info, format="html", fragment=False, template=None):
+        "Renders the template to a string using the provided info."
+        cherrypy.response.headers["Content-Type"] = "text/javascript"
+        return 'alert("JavascriptCodeGoesHere")'
+
+    # This method is not required for most uses of templates.
+    # It is specifically used for efficiently inserting widget
+    # output into Kid pages. It does the same thing render does,
+    # except the output is a generator of ElementTree Elements 
+    # rather than a string.
+    def transform(self, info, template):
+        "Render the output to Elements"
+        pass

Added: pypy/dist/pypy/translator/js/turbogears/upload.sh
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/turbogears/upload.sh	Fri Aug 25 17:16:46 2006
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+#This should be run from the directory where you checked out pypy-dist
+
+svn up rpython2javascript
+
+rm -f dist/*.egg
+python ./rpython2javascript/pypy/translator/js/turbogears/setup.py bdist_egg
+scp dist/*.egg ericvrp at codespeak.net:public_html/rpython2javascript
+
+#python ./rpython2javascript/pypy/translator/js/turbogears/setup.py register



More information about the Pypy-commit mailing list