Hy,
is there any event-drive/event-based Webframework for Python?
I mean something like NitroGen is for erlang.
You simply get some components you add to a website (like a button) and accociate a python-function to the “onclick”-handler of the button and it gets executed. It should generate all needed html and js core for me (just as nitrogen does) and support all needed components (like span, p, button, textbox, passwordfield…)
Like the following code:
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.Button import Button
from pyjamas import Window
def greet(fred):
Window.alert("Hello, AJAX!")
if __name__ == '__main__':
b = Button("Click me", greet)
RootPanel().add(b)
which gets this.
The only framework I found is PyJamas but it is made for Web-Applications (so things like Webmailers) and not for Web-Pages (where google needs content to index and which should be readable without js, with limited functionality). So is there something similar like PyJamas or Nitrogen?
Thanks!
KSS (Kinetic Style Sheets) provides something similar to NitroGen. Although KSS differs from NitroGen in that it defines a simple domain-specific language (DSL) for declaring how JavaScript events should be bound to an HTML page on the client side, and this DSL can also declare that events need to trigger a server-side component via AJAX. With NitroGen and PyJamas the information containing how the JavaScript interacts with the HTML is deduced from data structures that are part of a server-side language.
http://kssproject.org/
From the KSS project description, “KSS has both a client-side Javascript library and server-side support. The client-side Javascript library needs to be included in your page. It fetches Kinetic style sheets from the server, parses them and binds a set of action to browser events and/or page elements. It is clean Javascript code that can peacefully coexist with other clean Javascript librarys like JQuery or ExtJS.”
KSS can be used independant of any Python or server-side code. However, there are facilities in KSS for binding KSS client-side events back to server-side callables in a Python web framework. There are bindings to use KSS with many of Python’s popular web frameworks (Django, Pylons, Zope, Plone, Grok).