easymode.admin.utils

easymode.admin.models.fields

Fields to be used in models.

class easymode.admin.models.fields.FlashUrlField(*args, **kwargs)

A field that is an url in flash.

A valid flash url must be one of:

  1. an absolute url, eg. http://example.com/
  2. a relative url, eg. /main/chapter
  3. a flash url with a hash eg. #/main/chapter
class easymode.admin.models.fields.RelativeFilePathField(base, relative_path, match=None, recursive=False, required=True, widget=None, label=None, initial=None, help_text=None, path='', *args, **kwargs)

A FilePathField which stores paths as relative paths.

Parameters:
  • base – The base path, this base path will NOT be in the database (eg. settings.PROJECT_DIR).
  • relative_path – The relative part of the path, which will be in the database, together with the filename.
class easymode.admin.models.fields.XmlField(*args, **kwargs)

Used to store XML.

When using easymode.tree.xml(), all data is escaped and html tags are turned into entities. Using this field will make sure the escaping is skipped, so xml is rendered unmodified.

class easymode.admin.models.fields.SafeTextField(*args, **kwargs)

Removes all cariage returns from the input.

This class should be used instead of django.db.models.TextField, if you want to use easymode’s gettext facilities. It will strip all cariage returns from the input. Cariage returns are an error when included in gettext message id’s. It also allows you to specify the number of rows and columns of the textarea.

Parameters:
  • rows – The number of rows of the textarea.
  • cols – The number of columns of the textarea.
class easymode.admin.models.fields.SafeHTMLField(*args, **kwargs)

A html field with the following properties:

  1. Escapes cariage returns
  2. Will render as html, without escaping < and >
  3. Validates that html and will log errors when invalid html is discovered, instead of crash.
  4. Allows the max_length attribute, the max_length is then computed, without counting markup. Also html entities are converted to normal characters before measuring the length as well.
  5. accepts tinymce configuration options.

usage:

html = SafeHTMLField(_('some rich text'), max_length=200, width=300, height=100, buttons="link,unlink,code")
Parameters:
  • max_length – The maximum length of the text, after stripping markup and converting html entities to normal characters.
  • width – The width of the html editor in the admin
  • height – The height of the html editor in the admin
  • buttons – Configuration for the theme_advanced_buttons1. The default is “bullist,numlist,|,undo,redo,|,link,unlink,|,code,|,cleanup,removeformat”.

easymode.admin.forms.fields

Fields to be used in forms.

class easymode.admin.forms.fields.FlashUrlField(max_length=None, min_length=None, *args, **kwargs)

A field that validates input to be either

  1. an absolute url, eg. http://example.com/
  2. a relative url, eg. /main/chapter
  3. a flash url with a hash eg. #/main/chapter
class easymode.admin.forms.fields.HtmlEntityField(max_length=None, min_length=None, *args, **kwargs)

A form field that can validate the length of a rich text field.

It ignores html markup and it counts html entities as only a single character.

class easymode.admin.forms.fields.PoSafeTextField(max_length=None, min_length=None, *args, **kwargs)

Having carriage return in po files is an error. This field’s clean function will strip these ugly characters from the input.

Table Of Contents

Previous topic

easymode.utils

Next topic

easymode.debug