Python

Formunuclous 2.2.0 Released

September 16, 2010

Formunculous 2.2.0 Builder ScreenshotToday I released version 2.2.0 of Formunculous.  Check out the release notes or download it by going to the Formunculous Website.  This release was primarily bug fixes and interface improvements.

Django Render a Context Variable as a Template

June 30, 2010

I had a small itch to scratch, and I thought it would be fun to write a template tag that renders the passed in parameter as a template with the current pages context.  So for example on a blog or flatpages page, if you used this with the pages content variable, it would render any template tags/filters that is contained in that content.

from django import template
from django.template import TemplateSyntaxError, Variable, Template
from django.utils.translation import ugettext as _

register = template.Library()

class RenderAsTemplate(template.Node):

    def __init__(self, variable):

        self.variable = Variable(variable)

    def render(self, context):

        t = Template(self.variable.resolve(context))

        return t.render(context)


def render_as_template(parser, token):

    bits = list(token.split_contents())

    if len(bits) < 2:
        raise TemplateSyntaxError, _('%r tag requires at least one argument') % bits[0]

    return RenderAsTemplate(bits[1])

render_as_template = register.tag(render_as_template)

As an example you could do something like:

{% load render_as_template %}

.
.
.
{% render_as_template "{% ssi '/path/to/include' %}" %}

and it would actually perform the server side include. It also passes in the context of the page, so if you had a variable called entry.page you could call:

{% render_as_template "{{ entry.page }}" %}

and it would render as the content of the entry.page variable.

 

I passed simple strings to the template tag in the examples above, but you can pass template variables so if you have entry.page and it contained some template tags or filters in it, you could call:

{% render_as_template entry.page %}

and it would render the contents of that variable as a template.

Django Remote Include and RSS to HTML Template Tags

June 30, 2010

I wrote some pretty cool template tags last night for Django.  One that you can use to include the content of a remote URL into a template, and another that pulls down an RSS/Atom feed and writes it out as CSS classed HTML.

Both of them can run in simple or cached mode.  In cached mode, they cache the results for a specified amount of time in seconds.

Here are the tags:

remote_include.py

rss2html.py

The rss2html.py tag requires the Universal Feed Parser in the same directory as rss2html.py or at least on the python path.

Here is a template example for using both tags:

<html>
  <head>
    <titleTemplate Tag Testing</title>
  </head>
  <body>
    <h1>Remote Include - No caching</h1>
    {% sri http://carsongee.com/ %}
    <h1>Remote Include - Caching for One Hour</h1>
    {% cri http://carsongee.com/ 3600 %}
    <h1>RSS 2 HTML - No Caching</h1>
    {% rss2html http://carsongee.com/rss.xml %}
    <h1>RSS 2 HTML - Caching for One Hour</h1>
    {% rss2htmlcache http://carsongee.com/rss.xml 3600 %}
    <h1>RSS 2 HTML - Caching or Not - Specify Number of Entries</h1>
    {# Grab first 3 entries #}
    {% rss2html http://carsongee.com/rss.xml 3 %}
    {% rss2htmlcache http://carsongee.com/rss.xml 3600 3 %}
  </body>
</html>

That is pretty much all there is to it. Let me know in the comments if you have any issues.

Formunculous 2.1.1 Available

June 23, 2010

Just finished a bugfix release for Formunculous. So feel free to go grab it. Or install it straight from the command line with:

easy_install formunculous

now that it is in the cheese shop.

 

Here is the small list of changes:

  • Now fully compatible with both Django 1.1 and 1.2 (any bugfix release)
  • Word fixes (replacing "Application" with "Form" - legacy problem)
  • Minor HTML and CSS fixes
  • Completed form sorting and paging fixes

Formunculous Website Launched

May 10, 2010

Formunculous Website screenshot

I have been somewhat feverishly working on the design and implementation of a project Website for Formunculous, and I am really quite happy with the results.  I've really been focusing on a visual design and illustration skills as of late, and I thought I would be fun to show off some of those results using a Website I've wanted to create for quite some time.  Let me know what you think.

Formunculous 2.1 Release

April 12, 2010

New Statistics FeatureThis is a new feature release that adds several graphical statistics, CSV export, and form history views among many others. This release focused on increasing usability and user interface design.

Features and Bugs Fixes

New features:

  • Graphical statistics for showing responses over time.
  • Pie charts for showing percentage choices for drop down type fields.
  • Improved notification e-mail with direct links to related areas of the app.
  • Interface improvements on form index page--tab with forms available for review.
  • New review tab shows the number of complete and incomplete forms for each form.
  • Incomplete forms are now shown on the reviewing view along with the completion percentage.
  • There are now print links on the completion page and review page for forms.
  • Link to download all of the files associated with a form definition as a single zip file.
  • There is a link to export all form submission data as a single CSV.
  • Restyle of form building view to make it more compact.
  • The accordion expansion handle for form building is now available in a larger area.
  • In the builder index, inactive forms are now greyed out.
  • Each column in the builder index is now sortable.
  • Input errors for the end user have an improved look and feel
  • If you have an authenticated multi-use form, the user can now view each form that they have previously filled out.

Bug Fixes:

  • Sorting on the review index has been improved to include fields with the special "None" value.
  • Searching forms in the review index now properly cases and trims the search terms.
  • The preview form no longer shows the submit/save buttons.
  • Copying a form definition now properly performs a deep copy of dropdown selections and sub-forms.
  • Copying a form definition now properly copies the site status and list of reviewers.
  • Notification for non-authenticated forms no longer sends multiple e-mail notifications if the user refreshes the page.
  • Verification of whether the requested form is a parent or child is now working properly.

Django Admin Integration

February 28, 2010

I love python and Django is probably the best Web application framework I have ever worked with, but it isn't without its issues.  It has an absolutely great built-in, auto-generated admin interface for directly modifying database objects.  It is incredibly convenient and takes care of most common Web application administration needs for the vast majority of applications.  That being said, if it doesn't work for your application it can be painful to shim extended admin interfaces into it.  

For example it doesn't really fit with Formunculous or File Manager than it is pretty much the exact opposite of convenient.  I have wrestled with integrating other application's admin interfaces into the Django admin with out much success.  The look and feel is easy thanks to template extensions, but just creating a simple link to your extended admin views is just not there, and there isn't really a recommended way to do it.

Formunculous 2.0 Released

January 30, 2010

I just released a new version of formunculous to the Internets.  It has

a bunch of new features for managing database or email backed Web forms.  It offers a lot of new functionality, and continues to bring easy form creation and processing.  Check it out at the Formunculous Source Forge page.

Here are the release notes:

Formunculous Project Released

November 19, 2009

I've posted a code project on SourceForge I've been working on for the last couple months called formunculous.  The project page is at sf.net/projects/formunculous. It is a Django application that makes creating database or email based forms easy.  It uses a fairly advanced drag and drop based interface for building forms.  It can be used for anything from simple email contact forms to complex authenticated applications for programs, event registrations, etc.  It handles several types of data including files, pictures, and documents.