Example #1
0
    def __unicode__(self):
        result = []
        values = self.value

        if not self.multi_valued \
            or self.multi_valued and not isinstance(values, (list, tuple)):
            values = [values]

        for value in values:
            value = utils._from_python(value)
            if value is not None:
                if self.boost:
                    boost_attr = ' boost="%s"' % self.boost
                else:
                    boost_attr = ''
                    
                xml = '<field name="%s"%s><![CDATA[%s]]></field>\n'
                result.append(xml % (self.get_name(), boost_attr, value))
            else:
                result.append('')

        if self.multi_valued:
            return '\n'.join(result)

        return result[0]
Example #2
0
 def items(self):
     temp_list = []
     for key, value in  super(Query, self).items():
         if isinstance(value, CleverDict):
             temp_list.extend(value.items())
         elif isinstance(value, list):
             temp_list.append((key,value))
         else:
             temp_list.append(('%s' % key, utils._from_python(value)))
     return temp_list
Example #3
0
 def __unicode__(self):
     field_str = ''
     values = self.value
     
     if values is not None:
         if not hasattr(values, '__iter__'):
             values = [values]
             
         for value in values:
             field_str += u'<field name="%s"><![CDATA[%s]]></field>\n' % (
                 self.get_name(), utils._from_python(value))
                 
     return field_str
Example #4
0
 def items(self):
     temp_list = []
     for key, value in  super(Query, self).items():
         if key == 'fq':
             # fq is handled below, doing it here would cause duplicates
             continue
         if isinstance(value, CleverDict):
             temp_list.extend(value.items())
         elif isinstance(value, list):
             temp_list.append((key,value))
         else:
             temp_list.append(('%s' % key, utils._from_python(value)))
     for v in self.fq:
         temp_list.append(('fq', v))
     return temp_list
Example #5
0
 def __unicode__(self):
     return '<field name="%s"><![CDATA[%s]]></field>\n' % (self.get_name(), utils._from_python(self.value))
Example #6
0
 def __unicode__(self):
     value = utils._from_python(self.value)
     if value is not None:
         return '<field name="%s"><![CDATA[%s]]></field>\n' % (self.get_name(), value)
     else:
         return ''