views:

590

answers:

5

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!

A: 

twisted matrix?

sean riley
Its to lowlevel, im searching for something which knows of the components I want to place onto a html page and generates the needed html and js-code to connect it to my python-code.
theomega
A: 

Turbo Gears?

i can google all day!

sean riley
TG is not eventbased. You dont help me by googleing webframeworks, I already used some of them, I know the market here, the question is more specific
theomega
+2  A: 

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).

Wheat
+1  A: 

HTML is not event-driven, so you can't make an event-driven web framework like that without resorting to Ajax, and you didn't want that. So the answer is no, because such a thing is simply impossible,

What I suspect you mean rather than event-driven, is that you have a system where you define up a schema and has forms generated for you. And every Web framework has that.

But of you like components and event driven development, look into the Zope Toolkit based web frameworks, i.e. Grok, Repoze.BFG, Zope3 and the newest of them: Bobo.

http://grok.zope.org/ http://bfg.repoze.org/ http://wiki.zope.org/zope3/Zope3Wiki http://bobo.digicool.com/

Edit: OK, evidently the problem was only with Pyjamas, not using Javascript. In that case KSS, as mentioned above works. And it's useable with the frameworks above!

Lennart Regebro
HTML alone is not event-driven but using ajax it can be. So as i wrote in my question, im searching for a toolkit to generate the html and the js. But the simple (non-dynamic, non-eventbased content) should be in the html for seo puroposes. I hope you now understand.
theomega
Ah, of course. And you are saying PyJamas can't do that? That kinda sucks, in that case...
Lennart Regebro
+1  A: 

Zope 3 might suit your purposes (when used on top of Twisted, as it now may be), and so might Divmod Mantissa -- they're surely both strongly event-driven, especially Mantissa, and _any_thing but "low-level", especially Zope (indeed a frequent complaint about the latter is that it's just too rich and high-level to master;-).

Alex Martelli