[IronPython] Python Pages -- web application stack (like django, rails, ...)

Jonathan Slenders jonathan at slenders.be
Thu Jun 12 01:09:01 CEST 2008

Hi all,

I'm working on a web application framework in Python, and just uploaded the
first release.

Now I quote from my own README. What it actually does is:

- Provide an easy way to embed Python code into HTML, similar to PHP, JPS
  other server side languages.
- Make reusing HTML very easy. It uses concepts like master pages and
  including of other pages as a control. This is a very rich template
- when pages act like web controls for other pages, they are simply
available as
  a member variable of the other pages.
- It contains a built-in HTTP/1.1 web server but also supports CGI.
- Uses clean URLs. There are no .page extensions, and suffixes are available
  as a variable. For instance, if there's a page /test.page, then the URL
  /test/abc will render /test.page, but receive the suffix /abc. This is
  not a new concept, but just very easy to use.
- Output filters for post processing of the generated XHTML tree.
- URLs will always be relative to the page where they've been generated.
  This makes it very easy for included pages to use URLs relative to their
  own even if their in a totally different directory. (This mechanism
  requires an output filter.)
- The render engine has built-in debug functionality. The current
  web based debugger isn't yet ready to use, but the back-end
  has already been implemented.

The target audience is at the moment mainly for programmers, because the
front-end (which I considered less important until now) is uncomplete.

The core has been extensively tested and works pretty well, but some minory
features are missing and therefore I consider the whole alpha quality.

I'm constantly trying to get everything work in IronPython because that's
definitely a great bonus. Until now, it doesn't run in IronPython because it
executes part of the pages though eval while the globals/locals for these
parts are each time passed on the next eval call. (bugs has been submitted
on codeplex, see user:jonathanslenders)

It does however work already with Silverlight. A page can dynamically build
a xap file with Python code in. Thanks to Harry Pierson for the tip!
Because I'm really new to Silverlight and don't know much about it's
capabilities, some research needs to be done, to get the best of this
integration. -- But the concept works very well.

To give you all an idea of the layout of such pages:
One page (a master) may look like this.

<%!page output="xhtml" filters="resolve_uris,highlight_code" %>
<%!content placeholder="Main" %>
        <%!placeholder id="head" %>
        <%!placeholder id="content" %>

and another may implement his placeholders. This one does some math. Note
the modified python syntax. My compiler compiles these pages to regular
python classes.

<%!page master="/Master" external="true" %>
<%!content placeholder="head" %>
<title>Hello world page</title>
<%!content placeholder="content" %>
    Let's count to 10:
    <% for i in range(0,10): %>
        <li><%= i %></li>
    <% endfor; %>
def factorial(i):
    if i == 0:
        return 1;
        return i * factorial(i - 1);
    The factorial of 10 is <%= factorial(10) %>

And the Silverlight control:

<%!page master="/controls/silverlight-xap" external="true" %>
<%!content name="python" %>
from System.Windows import Application
from System.Windows.Controls import Canvas
xaml = Application.Current.LoadRootVisual(Canvas(), "app.xaml")
xaml.textblock.Text = 'Hello world from IronPython'
<%!content name="xaml" %>
<Canvas x:Class="System.Windows.Controls.Canvas"
<TextBlock x:Name="textblock" FontSize="30">Hello world from XAML

The source code is available here:


I hope someone thinks this is interesting.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080612/8d90c60e/attachment.html>

More information about the Ironpython-users mailing list