Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
CMFDefault.formlib.widgets.SubjectInputWidget Class Reference
Inheritance diagram for CMFDefault.formlib.widgets.SubjectInputWidget:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.formlib.widgets.SubjectInputWidget:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getInputValue
def hasInput
def __call__

Public Attributes

 vocabulary

Private Member Functions

def _getWidget

Private Attributes

 _widgets
 _widget_keys

Detailed Description

Definition at line 110 of file widgets.py.


Constructor & Destructor Documentation

def CMFDefault.formlib.widgets.SubjectInputWidget.__init__ (   self,
  context,
  request 
)

Definition at line 115 of file widgets.py.

00115 
00116     def __init__(self, context, request):
00117         super(SubjectInputWidget, self).__init__(context, request)
00118         self._widgets = {}
00119         self._widget_keys = (1,)
00120         self.vocabulary = ()
00121         context = getattr(self.context.context, 'context',
00122                           self.context.context)
00123         mdtool = getUtility(IMetadataTool)
00124         allowed_subjects = mdtool.listAllowedSubjects(context)
00125         if allowed_subjects:
00126             items = [ (str(v), unicode(v), unicode(v))
00127                       for v in allowed_subjects ]
00128             self.vocabulary = SimpleVocabulary.fromTitleItems(items)
00129             self._widget_keys = (0, 1)


Member Function Documentation

Definition at line 160 of file widgets.py.

00160 
00161     def __call__(self):
00162         values = {0: [], 1: []}
00163         if not self._renderedValueSet():
00164             value = self.getInputValue()
00165         else:
00166             value = self._data
00167         for item in value or ():
00168             if item in self.vocabulary:
00169                 values[0].append(item)
00170             else:
00171                 values[1].append(item)
00172         for k in self._widget_keys:
00173             self._getWidget(k).setRenderedValue(set(values[k]))
00174         return '\n'.join([ self._getWidget(k)() for k in self._widget_keys ])

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 130 of file widgets.py.

00130 
00131     def _getWidget(self, i):
00132         if i not in self._widgets:
00133             if i == 0:
00134                 field = Set(__name__='1').bind(self.context)
00135                 widget = MultiSelectSetWidget(field, self.vocabulary,
00136                                               self.request)
00137                 widget.setPrefix(self.name)
00138                 widget.empty_marker_name = widget.name + "-empty-marker"
00139                 widget.size = 3
00140                 self._widgets[0] = widget
00141             elif i == 1:
00142                 field = Tuple(__name__='', required=False).bind(self.context)
00143                 widget = TupleInputWidget(field, self.request)
00144                 widget.name = self.name
00145                 widget.height = self.vocabulary and 2 or 6
00146                 self._widgets[1] = widget
00147         return self._widgets[i]

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 148 of file widgets.py.

00148 
00149     def getInputValue(self):
00150         value = set()
00151         for k in self._widget_keys:
00152             value = set(self._getWidget(k).getInputValue() or ())|value
00153         return value

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 154 of file widgets.py.

00154 
00155     def hasInput(self):
00156         value = False
00157         for k in self._widget_keys:
00158             value = self._getWidget(k).hasInput() or value
00159         return value

Here is the call graph for this function:


Member Data Documentation

Definition at line 118 of file widgets.py.

Definition at line 117 of file widgets.py.

Definition at line 119 of file widgets.py.


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