Ejemplo n.º 1
0
    def gen_autocomplete(self, qs, maxRows=None):
        '''generator of 3-elements tuples for autocomplete responses.

:parameter qs: the autocomplete query
:paramater maxRows: optional number of rows.
'''
        if maxRows:
            qs = qs[:int(maxRows)]
        for q in qs:
            l = to_string(q)
            yield l, l, q.id
Ejemplo n.º 2
0
    def gen_autocomplete(self, qs, maxRows = None):
        '''generator of 3-elements tuples for autocomplete responses.

:parameter qs: the autocomplete query
:paramater maxRows: optional number of rows.
'''
        if maxRows:
            qs = qs[:int(maxRows)]
        for q in qs:
            l = to_string(q)
            yield l, l, q.id
Ejemplo n.º 3
0
 def search(cls, q):
     c = cls.http()
     body = cls.data(q=q, maxRows=20, style='short')
     response = c.get(cls.search_url, data=body)
     if response.status_code == 200:
         data = json.loads(response.content.decode('utf-8'))
         qs = []
         all = set()
         if 'geonames' in data:
             for data in data['geonames']:
                 id = data.pop('geonameId', None)
                 if id:
                     el = cls(id=id, **data)
                     re = to_string(el)
                     if re not in all:
                         all.add(re)
                         qs.append(el)
         return qs
Ejemplo n.º 4
0
    def __init__(self, *children, **params):
        '''Initailize the form layout:

:parameter children: list of children to include in this
    :class:`BaseFormLayout`. Depending on the type, these children can be
    field names and/or other :class:``BaseFormLayout`.
:parameter legend: optional text to display as a legend above
    this:class:`BaseFormLayout`.'''
        self._children = children
        self.default_style = params.pop('default_style', self.default_style)
        self.show_field_labels = params.pop('show_field_labels',
                                            self.show_field_labels)
        legend = params.pop('legend', None)
        self.legend_html = to_string(legend or '')
        super(BaseFormLayout, self).__init__(**params)
        if self.legend_html:
            self.add(
                html.WidgetMaker(tag='div', cn=classes.legend, key='legend'))
Ejemplo n.º 5
0
 def search(cls, q):
     c = cls.http()
     body = cls.data(q=q, maxRows=20, style="short")
     response = c.get(cls.search_url, data=body)
     if response.status_code == 200:
         data = json.loads(response.content.decode("utf-8"))
         qs = []
         all = set()
         if "geonames" in data:
             for data in data["geonames"]:
                 id = data.pop("geonameId", None)
                 if id:
                     el = cls(id=id, **data)
                     re = to_string(el)
                     if re not in all:
                         all.add(re)
                         qs.append(el)
         return qs
Ejemplo n.º 6
0
    def __init__(self, *children, **params):
        '''Initailize the form layout:

:parameter children: list of children to include in this
    :class:`BaseFormLayout`. Depending on the type, these children can be
    field names and/or other :class:``BaseFormLayout`.
:parameter legend: optional text to display as a legend above
    this:class:`BaseFormLayout`.'''
        self._children = children
        self.default_style = params.pop('default_style', self.default_style)
        self.show_field_labels = params.pop('show_field_labels',
                                            self.show_field_labels)
        legend = params.pop('legend', None)
        self.legend_html = to_string(legend or '')
        super(BaseFormLayout, self).__init__(**params)
        if self.legend_html:
            self.add(html.WidgetMaker(tag='div',
                                      cn=classes.legend,
                                      key='legend'))
Ejemplo n.º 7
0
 def __unicode__(self):
     return to_string(self.__class__.__name__+'-{0}'.format(self.columns)+\
                      self.extra_identity())
Ejemplo n.º 8
0
 def __init__(self, path, location=None):
     self.path = path
     self.location = location
     self._code = to_string(uuid4())[:8]
Ejemplo n.º 9
0
 def __unicode__(self):
     return to_string(self.__class__.__name__+'-{0}'.format(self.columns)+\
                      self.extra_identity())
Ejemplo n.º 10
0
 def __init__(self, path, location=None):
     self.path = path
     self.location = location
     self._code = to_string(uuid4())[:8]