Table of Contents

Class: Field qm/fields.py

A Field is a named, typed component of a data structure.

Base Classes   
object
Methods   
FormatValueAsHtml
FormatValueAsText
GetBriefDescription
GetDefaultValue
GetDescription
GetHelp
GetHtmlFormFieldName
GetHtmlHelp
GetName
GetSubfields
GetTitle
GetValueFromDomNode
IsComputed
IsHidden
IsReadOnly
MakeDomNodeForValue
ParseFormValue
ParseTextValue
Validate
__init__
__repr__
  FormatValueAsHtml 
FormatValueAsHtml (
        self,
        server,
        value,
        style,
        name=None,
        )

Return an HTML rendering of a value for this field.

server
The WebServer in which the HTML will be displayed.
value
The value for this field. May be None, which renders a default value (useful for blank forms).
style
The rendering style. Can be "full" or "brief" (both read-only), or "new" or "edit" or "hidden".
name
The name to use for the primary HTML form element containing the value of this field, if style specifies the generation of form elements. If name is None, the value returned by GetHtmlFormFieldName() should be used.
returns
A string containing the HTML representation of value.
Exceptions   
NotImplementedError
  FormatValueAsText 
FormatValueAsText (
        self,
        value,
        columns=72,
        )

Return a plain text rendering of a value for this field.

columns
The maximum width of each line of text.
returns
A plain-text string representing value.
  GetBriefDescription 
GetBriefDescription ( self )

Return a brief description of this field.

This description is used when prompting for input, or when displaying the current value of the field.

  GetDefaultValue 
GetDefaultValue ( self )

Return the default value for this field.

  GetDescription 
GetDescription ( self )

Return a description of this field.

This description is used when displaying detailed help information about the field.

  GetHelp 
GetHelp ( self )

Generate help text about this field in structured text format.

Exceptions   
NotImplementedError
  GetHtmlFormFieldName 
GetHtmlFormFieldName ( self )

Return the form field name corresponding this field.

returns
A string giving the name that should be used for this field when used in an HTML form.
  GetHtmlHelp 
GetHtmlHelp ( self,  edit=0 )

Generate help text about this field in HTML format.

edit
If true, display information about editing controls for this field.
  GetName 
GetName ( self )

Return the name of the field.

  GetSubfields 
GetSubfields ( self )

Returns the sequence of subfields contained in this field.

returns
The sequence of subfields contained in this field. If there are no subfields, an empty sequence is returned.
  GetTitle 
GetTitle ( self )

Return the user-friendly title of the field.

  GetValueFromDomNode 
GetValueFromDomNode (
        self,
        node,
        attachment_store,
        )

Return a value for this field represented by DOM node.

This method does not validate the value for this particular instance; it only makes sure the node is well-formed, and returns a value of the correct Python type.

node
The DOM node that is being evaluated.
attachment_store
For attachments, the store that should be used.

If the node is incorrectly formed, this method should raise an exception.

Exceptions   
NotImplementedError
  IsComputed 
IsComputed ( self )

Returns true if this field is computed automatically.

returns
True if this field is computed automatically. A computed field is never displayed to users and is not stored should not be stored; the class containing the field is responsible for recomputing it as necessary.
  IsHidden 
IsHidden ( self )

Returns true if this Field should be hidden from users.

returns
True if this Field should be hidden from users. The value of a hidden field is not displayed in the GUI.
  IsReadOnly 
IsReadOnly ( self )

Returns true if this Field cannot be modified by users.

returns
True if this Field cannot be modified by users. The GUI does not allow users to modify a read-only field.
  MakeDomNodeForValue 
MakeDomNodeForValue (
        self,
        value,
        document,
        )

Generate a DOM element node for a value of this field.

value
The value to represent.
document
The containing DOM document node.
Exceptions   
NotImplementedError
  ParseFormValue 
ParseFormValue (
        self,
        request,
        name,
        attachment_stores,
        )

Convert a value submitted from an HTML form.

request
The WebRequest containing a value corresponding to this field.
name
The name corresponding to this field in the request.
attachment_stores
A dictionary mapping AttachmentStore ids (in the sense of Python's id built-in) to the 'AttachmentStore's themselves.
returns
A pair (value, redisplay). value is the value for this field, as indicated in request. redisplay is true if and only if the form should be redisplayed, rather than committed. If an error occurs, an exception is thrown.
  ParseTextValue 
ParseTextValue ( self,  value )

Parse a value represented as a string.

value
A string representing the value.
returns
The corresponding field value. The value returned should be processed by Validate to ensure that it is valid before it is returned.
Exceptions   
NotImplemented
  Validate 
Validate ( self,  value )

Validate a field value.

For an acceptable type and value, return the representation of value in the underlying field storage.

value
A value to validate for this field.
returns
If the value is valid, returns value or an equivalent "canonical" version of value. (For example, this function may search a hash table and return an equivalent entry from the hash table.)

This function must raise an exception if the value is not valid. The string representation of the exception will be used as an error message in some situations.

Implementations of this method must be idempotent.

Exceptions   
NotImplementedError
  __init__ 
__init__ (
        self,
        name,
        default_value,
        title="",
        description="",
        hidden="false",
        read_only="false",
        computed="false",
        )

Create a new (generic) field.

name
The name of the field.
default_value
The default value for this field.
title
The name given this field when it is displayed in user interfaces.
description
A string explaining the purpose of this field. The description must be provided as structured text. The first line of the structured text must be a one-sentence description of the field; that line is extracted by GetBriefDescription.
hidden
If true, this field is for internal puprpose only and is not shown in user interfaces.
read_only
If true, this field may not be modified by users.
computed
If true, this field is computed automatically. All computed fields are implicitly hidden and implicitly read-only.

The boolean parameters (such as hidden) use the convention that true is represented by the string '"true"'; any other value is false. This convention is a historical artifact.

  __repr__ 
__repr__ ( self )


Table of Contents

This document was automatically generated on Mon Jan 3 09:42:29 2005 by HappyDoc version 2.1