def Vocabulary(self, content_instance=None): #If we have a method providing the list of types go with it, #it can always pull allowed_types if it needs to (not that we #pass the field name) value = ObjectField.Vocabulary(self, content_instance) if value: return value results = [] catalog = getToolByName(content_instance, 'portal_catalog') try: ws_path = content_instance.workspacePath() except AttributeError: ws_path = "/" if self.allowed_types: # we trust that all allowed_types are properly referencable and cataloged results = catalog(Type=self.allowed_types, path=ws_path) else: keys = catalog.uniqueValuesFor('UID') results = catalog(UID=keys, path=ws_path) #... but this should never happen results = [(r, r.getObject()) for r in results] value = [(r.UID, obj and (str(obj.Title().strip()) or \ str(obj.getId()).strip()) or \ log('Field %r: Object at %r could not be found' % \ (self.getName(), r.getURL())) or \ r.Title or r.UID) for r, obj in results] if not self.required: value.insert(0, ('', '<no reference>')) return DisplayList(value)