Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
plone.app.form.widgets.uberselectionwidget.UberSelectionWidget Class Reference
Inheritance diagram for plone.app.form.widgets.uberselectionwidget.UberSelectionWidget:
Inheritance graph
[legend]
Collaboration diagram for plone.app.form.widgets.uberselectionwidget.UberSelectionWidget:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def hidden
def error
def __call__
def getInputValue
def hasInput

Public Attributes

 source
 terms
 queryview

Static Public Attributes

tuple template = ViewPageTemplateFile('uberselectionwidget.pt')

Private Member Functions

def _value
def _getRenderValue

Static Private Attributes

 _error = None

Detailed Description

Definition at line 13 of file uberselectionwidget.py.


Constructor & Destructor Documentation

Reimplemented in plone.app.form.widgets.uberselectionwidget.UberMultiSelectionWidget.

Definition at line 18 of file uberselectionwidget.py.

00018 
00019     def __init__(self, field, request):
00020         SimpleInputWidget.__init__(self, field, request)
00021         self.source = field.source
00022         self.terms = getMultiAdapter((self.source, self.request), ITerms)
00023         self.queryview = getMultiAdapter((self.source, self.request), ISourceQueryView)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 68 of file uberselectionwidget.py.

00068 
00069     def __call__(self):
00070         value = self._getRenderValue()
00071         field = self.context
00072         results = []
00073         results_truncated = False
00074         qresults = self.queryview.results(self.name)
00075         if qresults is not None:
00076             for index, item in enumerate(qresults):
00077                 if index >= 20:
00078                     results_truncated = True
00079                     break
00080                 results.append(self.terms.getTerm(item))
00081         return self.template(field=field,
00082                              results=results,
00083                              results_truncated=results_truncated,
00084                              name=self.name,
00085                              value=value)

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in plone.app.form.widgets.uberselectionwidget.UberMultiSelectionWidget.

Definition at line 42 of file uberselectionwidget.py.

00042 
00043     def _getRenderValue(self):
00044         value = self._value()
00045         if value is not None:
00046             value = self.terms.getTerm(value)
00047         return value

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in plone.app.form.widgets.uberselectionwidget.UberMultiSelectionWidget.

Definition at line 24 of file uberselectionwidget.py.

00024 
00025     def _value(self):
00026         if self._renderedValueSet():
00027             value = self._data
00028         else:
00029             token = self.request.form.get(self.name)
00030 
00031             if token is not None and token != '':
00032                 if not isinstance(token, basestring):
00033                     token = token[-1]
00034                 try:
00035                     value = self.terms.getValue(str(token))
00036                 except LookupError:
00037                     value = self.context.missing_value
00038             else:
00039                 value = self.context.missing_value
00040 
00041         return value

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 62 of file uberselectionwidget.py.

00062 
00063     def error(self):
00064         if self._error:
00065             return getMultiAdapter((self._error, self.request),
00066                                    IWidgetInputErrorView).snippet()
00067         return ""

Here is the caller graph for this function:

Definition at line 86 of file uberselectionwidget.py.

00086 
00087     def getInputValue(self):
00088         value = self._value()
00089 
00090         field = self.context
00091 
00092         # Remaining code copied from SimpleInputWidget
00093 
00094         # value must be valid per the field constraints
00095         try:
00096             field.validate(value)
00097         except ValidationError, err:
00098             self._error = WidgetInputError(field.__name__, self.label, err)
00099             raise self._error
00100 
00101         return value

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 102 of file uberselectionwidget.py.

00102 
00103     def hasInput(self):
00104         if self.name in self.request or self.name+'.displayed' in self.request:
00105             return True
00106 
00107         token = self.request.form.get(self.name)
00108         if token is not None:
00109             return True
00110 
00111         return False

Here is the call graph for this function:

Definition at line 48 of file uberselectionwidget.py.

00048 
00049     def hidden(self):
00050         value = self._value()
00051         if value == self.context.missing_value:
00052             return '' # Nothing to hide ;)
00053 
00054         try:
00055             term = self.terms.getTerm(value)
00056         except LookupError:
00057             # A value was set, but it's not valid.  Treat
00058             # it as if it was missing and return nothing.
00059             return ''
00060 
00061         return '<input type="hidden" name="%s" value="%s" />' % (self.name, term.token)

Here is the call graph for this function:


Member Data Documentation

Definition at line 14 of file uberselectionwidget.py.

tuple plone.app.form.widgets.uberselectionwidget.UberSelectionWidget.template = ViewPageTemplateFile('uberselectionwidget.pt') [static]

The documentation for this class was generated from the following file: