[pypy-svn] r29164 - in pypy/dist/pypy/translator/js/demo: . jsdemo jsdemo/static jsdemo/static/css jsdemo/static/images jsdemo/static/javascript jsdemo/templates
fijal at codespeak.net
fijal at codespeak.net
Thu Jun 22 19:22:33 CEST 2006
Author: fijal
Date: Thu Jun 22 19:22:30 2006
New Revision: 29164
Added:
pypy/dist/pypy/translator/js/demo/
pypy/dist/pypy/translator/js/demo/__init__.py
pypy/dist/pypy/translator/js/demo/dev.cfg
pypy/dist/pypy/translator/js/demo/jsdemo/
pypy/dist/pypy/translator/js/demo/jsdemo/__init__.py
pypy/dist/pypy/translator/js/demo/jsdemo/autopath.py
pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py
pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py
pypy/dist/pypy/translator/js/demo/jsdemo/proxy.py
pypy/dist/pypy/translator/js/demo/jsdemo/static/
pypy/dist/pypy/translator/js/demo/jsdemo/static/css/
pypy/dist/pypy/translator/js/demo/jsdemo/static/images/
pypy/dist/pypy/translator/js/demo/jsdemo/static/javascript/
pypy/dist/pypy/translator/js/demo/jsdemo/templates/
pypy/dist/pypy/translator/js/demo/jsdemo/templates/__init__.py
pypy/dist/pypy/translator/js/demo/jsdemo/templates/bnb.html
pypy/dist/pypy/translator/js/demo/jsdemo/templates/bnb.kid
pypy/dist/pypy/translator/js/demo/jsdemo/templates/main.kid
pypy/dist/pypy/translator/js/demo/jsdemo/templates/master.kid
pypy/dist/pypy/translator/js/demo/jsdemo/templates/welcome.kid
pypy/dist/pypy/translator/js/demo/jsdemo/templates/xmlhttp.kid
Log:
Added files that seems to be necessary.
Added: pypy/dist/pypy/translator/js/demo/__init__.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/__init__.py Thu Jun 22 19:22:30 2006
@@ -0,0 +1 @@
+
Added: pypy/dist/pypy/translator/js/demo/dev.cfg
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/dev.cfg Thu Jun 22 19:22:30 2006
@@ -0,0 +1,46 @@
+# This is where all of your settings go for your development environment
+
+[global]
+
+# DATABASE
+
+# pick the form for your database
+# sqlobject.dburi="postgres://username@hostname/databasename"
+# sqlobject.dburi="mysql://username:password@hostname:port/databasename"
+# sqlobject.dburi="sqlite:///file_name_and_path"
+
+# for Windows users, sqlite URIs look like:
+# sqlobject.dburi="sqlite:///drive_letter|/path/to/file"
+
+
+# VIEW
+
+# kid.outputformat="html"
+
+# The sitetemplate is used for overall styling of a site that
+# includes multiple TurboGears applications
+# tg.sitetemplate="<packagename.templates.templatename>"
+
+
+# SERVER
+
+# Some server parameters that you may want to tweak
+server.socketPort=8080
+server.socketHost="127.0.0.1"
+
+# Disable the debug output at the end on pages.
+# logDebugInfoFilter.on = False
+server.logFile="server.log"
+server.logToScreen=True
+
+server.environment="production" #"development"
+#autoreload.package="testme"
+autoreload.on = False
+
+sessionFilter.on = True
+sessionFilter.storageType = "Ram"
+sessionFilter.cookieName = "BnB"
+
+[/static]
+staticFilter.on = True
+staticFilter.dir = "static"
Added: pypy/dist/pypy/translator/js/demo/jsdemo/__init__.py
==============================================================================
Added: pypy/dist/pypy/translator/js/demo/jsdemo/autopath.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/autopath.py Thu Jun 22 19:22:30 2006
@@ -0,0 +1,112 @@
+"""
+self cloning, automatic path configuration
+
+copy this into any subdirectory of pypy from which scripts need
+to be run, typically all of the test subdirs.
+The idea is that any such script simply issues
+
+ import autopath
+
+and this will make sure that the parent directory containing "pypy"
+is in sys.path.
+
+If you modify the master "autopath.py" version (in pypy/tool/autopath.py)
+you can directly run it which will copy itself on all autopath.py files
+it finds under the pypy root directory.
+
+This module always provides these attributes:
+
+ pypydir pypy root directory path
+ this_dir directory where this autopath.py resides
+
+"""
+
+
+def __dirinfo(part):
+ """ return (partdir, this_dir) and insert parent of partdir
+ into sys.path. If the parent directories don't have the part
+ an EnvironmentError is raised."""
+
+ import sys, os
+ try:
+ head = this_dir = os.path.realpath(os.path.dirname(__file__))
+ except NameError:
+ head = this_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
+
+ while head:
+ partdir = head
+ head, tail = os.path.split(head)
+ if tail == part:
+ break
+ else:
+ raise EnvironmentError, "'%s' missing in '%r'" % (partdir, this_dir)
+
+ pypy_root = os.path.join(head, '')
+ try:
+ sys.path.remove(head)
+ except ValueError:
+ pass
+ sys.path.insert(0, head)
+
+ munged = {}
+ for name, mod in sys.modules.items():
+ fn = getattr(mod, '__file__', None)
+ if '.' in name or not isinstance(fn, str):
+ continue
+ newname = os.path.splitext(os.path.basename(fn))[0]
+ if not newname.startswith(part + '.'):
+ continue
+ path = os.path.join(os.path.dirname(os.path.realpath(fn)), '')
+ if path.startswith(pypy_root) and newname != part:
+ modpaths = os.path.normpath(path[len(pypy_root):]).split(os.sep)
+ if newname != '__init__':
+ modpaths.append(newname)
+ modpath = '.'.join(modpaths)
+ if modpath not in sys.modules:
+ munged[modpath] = mod
+
+ for name, mod in munged.iteritems():
+ if name not in sys.modules:
+ sys.modules[name] = mod
+ if '.' in name:
+ prename = name[:name.rfind('.')]
+ postname = name[len(prename)+1:]
+ if prename not in sys.modules:
+ __import__(prename)
+ if not hasattr(sys.modules[prename], postname):
+ setattr(sys.modules[prename], postname, mod)
+
+ return partdir, this_dir
+
+def __clone():
+ """ clone master version of autopath.py into all subdirs """
+ from os.path import join, walk
+ if not this_dir.endswith(join('pypy','tool')):
+ raise EnvironmentError("can only clone master version "
+ "'%s'" % join(pypydir, 'tool',_myname))
+
+
+ def sync_walker(arg, dirname, fnames):
+ if _myname in fnames:
+ fn = join(dirname, _myname)
+ f = open(fn, 'rwb+')
+ try:
+ if f.read() == arg:
+ print "checkok", fn
+ else:
+ print "syncing", fn
+ f = open(fn, 'w')
+ f.write(arg)
+ finally:
+ f.close()
+ s = open(join(pypydir, 'tool', _myname), 'rb').read()
+ walk(pypydir, sync_walker, s)
+
+_myname = 'autopath.py'
+
+# set guaranteed attributes
+
+pypydir, this_dir = __dirinfo('pypy')
+
+if __name__ == '__main__':
+ __clone()
Added: pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py Thu Jun 22 19:22:30 2006
@@ -0,0 +1,13 @@
+
+""" xmlhttp controllers, usefull for testing
+"""
+
+import turbogears
+import cherrypy
+from pypy.jsdemo.jsdemo.controllers import Root
+from pypy.rpython.ootypesystem.bltregistry import BasicExternal
+
+# Needed double inheritance for both server job
+# and semi-transparent communication proxy
+class BnbRoot(Root, BasicExternal):
+ @turbogears.expose
Added: pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py Thu Jun 22 19:22:30 2006
@@ -0,0 +1,63 @@
+import turbogears
+from turbogears import controllers
+import cherrypy
+
+import autopath
+
+from pypy.translator.js.test.runtest import compile_function
+from pypy.translator.js.modules import dom,xmlhttp
+
+import thread
+import os
+
+def move_it():
+ pass
+
+def js_fun():
+ document = dom.get_document()
+ obj = document.createElement('img')
+ obj.id = 'gfx'
+ obj.setAttribute('style', 'position:absolute; top:0; left:0;')
+ obj.src = '/static/gfx/BubBob.gif'
+ document.body.appendChild(obj)
+
+def esc_html(data):
+ return data.replace("&", "&").replace("<", "<").replace(">", ">") \
+ .replace("\n", "<br/>").replace(" ", " ")
+
+class Root(controllers.Root):
+ def __init__(self):
+ self.lock = thread.allocate_lock()
+ self.lock.acquire()
+ self.results = None
+
+ @turbogears.expose(html="jsdemo.templates.main")
+ def index(self):
+ import time
+ return dict(now=time.ctime(), onload=self.jsname, code=self.jssource)
+
+ @turbogears.expose(format="json")
+ def send_result(self, result, exc):
+ self.results = (result, exc)
+ self.lock.release()
+ return dict()
+
+ def get_some_info(self, *args, **kwargs):
+ print "Info: %s" % cherrypy.response.body.read()
+ return dict()
+
+ get_some_info.exposed = True
+
+ def js_basic_js(self):
+ def gen(data):
+ yield data
+
+ cherrypy.response.headerMap['Content-Type'] = 'test/javascript'
+ cherrypy.response.headerMap['Content-Length'] = len(self.jssource)
+ return gen(self.jssource)
+
+ def wait_for_results(self):
+ self.lock.acquire()
+ self.lock.release()
+
+ js_basic_js.exposed = True
Added: pypy/dist/pypy/translator/js/demo/jsdemo/proxy.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/proxy.py Thu Jun 22 19:22:30 2006
@@ -0,0 +1,25 @@
+
+""" xmlhttp controllers, usefull for testing
+"""
+
+import turbogears
+import cherrypy
+from pypy.translator.js.demo.jsdemo.controllers import Root
+from pypy.rpython.ootypesystem.bltregistry import BasicExternal, MethodDesc
+
+# Needed double inheritance for both server job
+# and semi-transparent communication proxy
+class ProxyRoot(Root, BasicExternal):
+ """ Class for running communication tests which are not designed to end
+ after single function call
+ """
+ _methods = {
+ 'send_result' : MethodDesc((('result', "aa"), ('exc', "aa"), ('callback',(lambda : None))), None)
+ }
+
+ @turbogears.expose(html="jsdemo.templates.xmlhttp")
+ def index(self):
+ import time
+ return dict(now=time.ctime(), onload=self.jsname, code=self.jssource)
+
+ProxyRootInstance = ProxyRoot()
Added: pypy/dist/pypy/translator/js/demo/jsdemo/templates/__init__.py
==============================================================================
Added: pypy/dist/pypy/translator/js/demo/jsdemo/templates/bnb.html
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/templates/bnb.html Thu Jun 22 19:22:30 2006
@@ -0,0 +1 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Added: pypy/dist/pypy/translator/js/demo/jsdemo/templates/bnb.kid
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/templates/bnb.kid Thu Jun 22 19:22:30 2006
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
+ <title>Bub'n'bros</title>
+ <script language="javascript" src="${std.tg_js}/MochiKit.js"/>
+ <script type="text/javascript" src="js_basic.js"/>
+ <script type="text/javascript">
+ function call_fun () {
+ result = undefined;
+ exc = undefined;
+ try {
+ result = ${onload}();
+ } catch ( e ) {
+ exc = e;
+ }
+ xml = new XMLHttpRequest();
+ xml.open('GET', 'http://localhost:8080/send_result?result='+result+';exc='+exc, true);
+ xml.send(null);
+ }
+ </script>
+</head>
+<body bgcolor="#FFFFFF" onLoad="call_fun()">
+ <p>This is a test!</p><br/>
+ <p>Code:</p><br/>
+ <pre>
+ ${code}
+ </pre>
+</body>
+</html>
Added: pypy/dist/pypy/translator/js/demo/jsdemo/templates/main.kid
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/templates/main.kid Thu Jun 22 19:22:30 2006
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
+ <title>Bub'n'bros</title>
+ <script language="javascript" src="${std.tg_js}/MochiKit.js"/>
+ <script type="text/javascript" src="js_basic.js"/>
+ <script type="text/javascript">
+ function call_fun () {
+ result = undefined;
+ exc = undefined;
+ try {
+ result = ${onload}();
+ } catch ( e ) {
+ exc = e;
+ }
+ xml = new XMLHttpRequest();
+ xml.open('GET', '/send_result?result='+result+';exc='+exc, true);
+ xml.send(null);
+ }
+ </script>
+</head>
+<body onLoad="call_fun()">
+ <p>This is a test!</p><br/>
+ <p>Code:</p><br/>
+ <pre>
+ ${code}
+ </pre>
+</body>
+</html>
Added: pypy/dist/pypy/translator/js/demo/jsdemo/templates/master.kid
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/templates/master.kid Thu Jun 22 19:22:30 2006
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?python import sitetemplate ?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:extends="sitetemplate">
+
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+ <title>Your title goes here</title>
+</head>
+
+<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'">
+ <div py:if="tg_flash" class="flash" py:content="tg_flash"></div>
+
+ <div py:replace="item[:]"/>
+</body>
+</html>
Added: pypy/dist/pypy/translator/js/demo/jsdemo/templates/welcome.kid
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/templates/welcome.kid Thu Jun 22 19:22:30 2006
@@ -0,0 +1,13 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
+ py:extends="'master.kid'">
+
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+ <title>Welcome to TurboGears</title>
+</head>
+
+<body>
+Ding dong. <a href="bnb">BnB</a>
+</body>
+</html>
Added: pypy/dist/pypy/translator/js/demo/jsdemo/templates/xmlhttp.kid
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/templates/xmlhttp.kid Thu Jun 22 19:22:30 2006
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
+ <title>XMLHTTP test</title>
+ <script language="javascript" src="${std.tg_js}/MochiKit.js"/>
+ <script type="text/javascript" src="js_basic.js"/>
+ <script type="text/javascript">
+ function call_fun () {
+ result = undefined;
+ exc = undefined;
+ try {
+ result = ${onload}();
+ } catch ( e ) {
+ exc = e;
+ xml = new XMLHttpRequest();
+ xml.open('GET', '/send_result?result=0;exc='+exc, true);
+ xml.send(null);
+ }
+ }
+ </script>
+</head>
+<body onLoad="call_fun()">
+ <p>This is a test!</p><br/>
+ <p>Code:</p><br/>
+ <pre>
+ ${code}
+ </pre>
+</body>
+</html>
More information about the Pypy-commit
mailing list