Найти - Пользователи
Полная версия: turbogears-local-js-link
Начало » Pyramid / Pylons / TurboGears » turbogears-local-js-link
1
pythonwin
всем привет!

Помогите пожалуйста:
как создать JSLink на файлики в свой_проект/static/javascript/имя_файла.js
mochikit = JSLink(“turbogears”, “js/MochiKit.js”)
<SCRIPT SRC=“/tg_widgets/turbogears/js/MochiKit.js” TYPE=“text/javascript”/>

а мне нужен

<SCRIPT SRC=“/static/javascript/MochiKit.js” TYPE=“text/javascript”/>


код предложенный на http://untidy.net/blog/2006/04/20/turbogears-local-js-link/
не подойдет, т.к. при рунается, что такая возможность будет предоставлена только в TG1.0b1

————————————————–

TurboGears Version Info

* turbogears 0.9a6
* nose 0.8.6
* configobj 4.3.1
* ruledispatch 0.5a0.dev-r2115
* setuptools 0.6a11
* formencode 0.5.1
* celementtree 1.0.5-20051216
* pastescript 0.5.1
* elementtree 1.2.6
* simplejson 1.3
* sqlobject 0.7.1dev-r1675
* cherrypy 2.2.1
* turbokid 0.9.5
* turbocheetah 0.9.5
* turbojson 0.9.2
* pyprotocols 1.0a0dev-r2082
* cheetah 1.0
* pastedeploy 0.5
* paste 0.5
* formencode 0.5.1
* kid 0.9.1
* cheetah 1.0
* elementtree 1.2.6

Installed Plugins
Identity Providers

* sqlobject (turbogears 0.9a6)
* sqlalchemy (turbogears 0.9a6)

tg-admin Commands

* info (turbogears 0.9a6)
* shell (turbogears 0.9a6)
* quickstart (turbogears 0.9a6)
* update (turbogears 0.9a6)
* sql (turbogears 0.9a6)
* i18n (turbogears 0.9a6)
* toolbox (turbogears 0.9a6)

Visit Managers

* sqlobject (turbogears 0.9a6)
* sqlalchemy (turbogears 0.9a6)

Template Engines

* kid (turbokid 0.9.5)
* cheetah (turbocheetah 0.9.5)
* json (turbojson 0.9.2)

Widget Packages

* dominclude (dominclude 1.0)
* lightbox (lightbox 2.0-p1)
* scriptaculous (scriptaculous 1.6)
* jumpmenu (jumpmenu 1.0)
* moofx (moofx 1.2.4w2)
* tinymce (turbotinymce 1.0.3)
* selectshuttle (select-shuttle 0.94)

TurboGears Extensions

* visit (turbogears 0.9a6)
* identity (turbogears 0.9a6)
* fastdata (tgfastdata 0.9a6)
pythonwin
пока сделал вот так:

from turbogears import widgets
from turbogears import startup
class Link_local(widgets.Resource):
name_packed = “static”
def __init__(self, mod, *args, **kw):
super(Link_local, self).__init__(*args, **kw)
self.mod = mod

def update_params(self, d):
super(Link_local, self).update_params(d)
d = “/%s%s/%s/%s” % (startup.webpath, self.name_packed,
self.mod,
self.name)

def __hash__(self):
return hash(self.mod + self.name)

def __eq__(self, other):
return self.mod == getattr(other, “mod”, None) and \
self.name == getattr(other, “name”, None)

class JSLink_local(Link_local):
template = “”“
<script type=”text/javascript“ src=”$link“ />
”“”

location = widgets.js_location.head

def __init__(self, *args, **kw):
location = kw.pop('location', None)
super(JSLink_local, self).__init__(*args, **kw)
if location:
if location not in js_location:
raise ValueError, “JSLink location should be in %s” % js_location
self.location = location

def add_for_location(self, location):
return location == self.location

retrieve_javascript = widgets.set_with_self

JSLink_local(“javascript”, “ajaxgrid.js”)

и получаю:
<SCRIPT SRC=“/static/javascript/ajaxgrid.js” TYPE=“text/javascript”>

но это всё как-то громоздко :(
Maximbo
Проблемма довольно подробно освещена на Trac Wiki:
* http://trac.turbogears.org/turbogears/wiki/WidgetPackages
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB