Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install axf

How to install axf

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install axf
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.0.1 Available View build log
Windows (64-bit)
0.0.1 Available View build log
Mac OS X (10.5+)
0.0.1 Available View build log
Linux (32-bit)
0.0.1 Available View build log
Linux (64-bit)
0.0.1 Available View build log
Lastest release
version 0.0.1 on Jun 1st, 2013

AXF is a collection of ToscaWidgets2 widgets with resources loading based on the AXEL Loader to perform resources loading so that it is possible to replace resources and load widgets from ajax requests.


axf can be installed from pypi:

easy_install axf


pip install axf

should just work for most of the users

Using Widgets

To start using AXF widgets you must add axel to your pages so that widgets can load their resources:

<script src="https://raw.github.com/amol-/axel/master/src/axel.js"></script>

The AXEL loader is used instead of standard ToscaWidgets2 resources injection to make possible to load the forms where they are used through jQuery.load, as resources loading and injection is performed by AXEL not response manipulation to append the resources to head or body is required.

If you want to load and submit forms through ajax requests in TurboGears consider using tgext.ajaxforms

Replacing resources required by the widgets can be performed using the AXEL loader. Most widgets will depend on jQuery and will load it from the jquery cdn, if your website uses jQuery and you want to use a different version of it you can easily replace it using:

axel.register('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');

Just place your register before displaying the widget and your version of the library will be used.

Each widget will list its resources with the name used to register them in AXEL, so that you can replace them.


axf.widgets.ajax_autocomplete_field.AjaxAutocompleteField is field that provides autocompletion based on select2 backed by a json based api. Each entry has to provide a text which is displayed to the user and an id which is submitted with the form. text and id can coincide for plain text autocompletion.

The field requires two parameters datasource and inverse_datasource are respectively the api to retrieve list of data available for the text written by the user and to retrieve the text corresponding to an already selected entry (for example in case of validation error or editing existing data)


city    = AjaxAutocompleteField(label=l_('City'), validator=validators.Validator(required=True),
                                placeholder=l_('Select City'),
  • jquery - jquery library
  • select2 - select2 library
  • select2-style - select2 stylesheet
datasource api

The API is required to accept a term to search as input, to return a list of {text: "value", id: "id"} entries and a marker to indicate if more data is available:

def get_cities(self, term='', **kw):
    return dict(more=False, results=[dict(text=c[1], id=c[0]) for c in cities_dict.items()])
datasource_inverse api

The API is required to accept an id as argument in the form /apiname/ID and return the text and id of the corresponding entry:

def city_from_id(self, city_id=None, **kw):
    return dict(text=cities_dict.get(city_id), id=city_id)


axf.widgets.ajax_single_select.AjaxSingleSelectField is a field that loads its data from a datasource api whenever another field changes. This can be used to implement cascading single select fields, where options available depend on another selection.

The field requires two parameters datasource which is the api to call to request for the data available on the value of the other field and onevent which is a tuple with a selector and a javascript event (currently ignored) which specifies which field should trigger data update. Whenever the field specified by the selector changes the single select field is reloaded asking to the datasource for the data.


category = forms.SingleSelectField(label=l_('Category'), options=Deferred(get_categories),
subcategory = AjaxSingleSelectField(label=l_('Sub Category'), onevent=('#category', 'change'), prompt_text=None,
  • jquery - jquery library
datasource api

The API is required to accept the current value of the field linked by onevent option and return a list of options for the AjaxSingleSelectField in the form {name: "name", value: "value"}:

def get_subcategories(self, selected=None, **kw):
    if not selected:
        return dict(options=[])
    return dict(options=[dict(name=c['name'], value=c['id']) for c in subcategories.get(selected, [])])

Subscribe to package updates

Last updated Jun 1st, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.