Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
plone.app.form.widgets.uberselectionwidget.UberMultiSelectionWidget Class Reference
Inheritance diagram for plone.app.form.widgets.uberselectionwidget.UberMultiSelectionWidget:
Inheritance graph
[legend]
Collaboration diagram for plone.app.form.widgets.uberselectionwidget.UberMultiSelectionWidget:
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('ubermultiselectionwidget.pt')

Private Member Functions

def _value
def _getRenderValue

Detailed Description

Definition at line 112 of file uberselectionwidget.py.


Constructor & Destructor Documentation

Reimplemented from plone.app.form.widgets.uberselectionwidget.UberSelectionWidget.

Definition at line 115 of file uberselectionwidget.py.

00115 
00116     def __init__(self, field, request):
00117         SimpleInputWidget.__init__(self, field, request)
00118         self.source = field.value_type.source
00119         self.terms = getMultiAdapter((self.source, self.request), ITerms)
00120         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 from plone.app.form.widgets.uberselectionwidget.UberSelectionWidget.

Definition at line 152 of file uberselectionwidget.py.

00152 
00153     def _getRenderValue(self):
00154         value = self._value()
00155         if value is not None:
00156             value = [self.terms.getTerm(x) for x in value]
00157         return value

Here is the call graph for this function:

Reimplemented from plone.app.form.widgets.uberselectionwidget.UberSelectionWidget.

Definition at line 121 of file uberselectionwidget.py.

00121 
00122     def _value(self):
00123         if self._renderedValueSet():
00124             value = self._data
00125         else:
00126             tokens = self.request.form.get(self.name)
00127 
00128             if tokens is not None:
00129                 value = []
00130                 for token in tokens:
00131                     try:
00132                         v = self.terms.getValue(str(token))
00133                     except LookupError:
00134                         pass # skip invalid values
00135                     else:
00136                         value.append(v)
00137                 # only keep unique items
00138                 r = []
00139                 seen = {}
00140                 for s in value:
00141                     if s not in seen:
00142                         r.append(s)
00143                         seen[s] = 1
00144                 value = r
00145             else:
00146                 if self.name+'.displayed' in self.request:
00147                     value = []
00148                 else:
00149                     value = self.context.missing_value
00150 
00151         return value

Here is the call 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

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

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