Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Python Web Framework that I wrote in 2009. Not anymore maintained.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example-project
Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 README.md
README.md

Dasornis is a highly-customizable Python Web Framework that I coded on March 2009. It consists of Routing, ORM, Templating, I18n and Form libraries. See the example application for details.

Usage Example

Defining Models

# queries.py

from dasornis.db import Entity, Query, Field

class Fruit(Entity):
    id = Field()
    name = Field()

class FindFruits(Query):
    entitiy = Fruit
    code = 'SELECT id,name FROM fruits'

class CreateFruit(Query):
    code = "INSERT INTO fruits(name) VALUES ('%s')"

Templates and Forms

# forms.py

from dasornis.forms import Form, Textbox

safe_text = r'[\w\s]+'

class NewFruit(Form):
  fruit_name = Textbox(name='fruit', label_i18n_key='fruit_name', is_required=True, min_length=3, max_length=10, pattern=safe_text)
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      py:strip='True'>
  <xi:include href="generate_form.html" />
  <head>
    <title>Add Fruit</title>
  </head>
  <body>
    <fieldset class='NewMessage'>
      <legend>Add Fruit</legend>
        Report Message: ${ i18n | report.message_key }
        <form method='POST' action='/add'>
          ${ generate_form(template.form) }
          <button>Send</button>
        </form>
    </fieldset>
  </body>
</html>

HTTP

# urls.py

from dasornis.core import URLMap,StaticContent
from static.urls import map as static_urls

import request_handlers

map = URLMap(
  ('^/add',request_handlers.NewFruit),
  ('^/logo',StaticContent('static/logo.gif')),
  ('^/static/(.+)',static_urls)
)
# request_handlers.py

from dasornis.core import HttpHandler
from dasornis.forms.validators import ValidateForm
from dasornis.template import Template
from dasornis import exceptions
import queries,forms

class NewFruit(HttpHandler):
  def init(self):
    self.template = Template(self,'add.html','genshi_engine')
    self.template.form = forms.NewFruit()
    self.template.args.append( ('fields',self.template.form._fields_) )

  def post(self):
    try:
      self.save()
    except exceptions.LengthError:
      self.report.report_type = self.report.ERROR
      self.report.message_key = 'length_error'
    except exceptions.MissingInfo:
      self.report.report_type = self.report.ERROR
      self.report.message_key = 'missing_info'

  @ValidateForm()
  def save(self):
    queries.CreateFruit(self.request.POST['fruit'])
    self.redirect('/list')
Something went wrong with that request. Please try again.