[Python] Google App Engine Search api proxy after Python 2.7 to Python 3 Conversion

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    When using the Python 2.7 of google app engine we were able to use this import

    from google.appengine.api import search



    One such area

    def search_update_index(self):
    """
    Updates the search index for this instance.

    This happens automatically on put.
    """
    doc_id = self.search_get_document_id(self.key)

    fields = [search.AtomField('class_name', name) for name in self.search_get_class_names()]

    index = self.search_get_index()

    if self.searchable_fields is None:
    searchable_fields = []

    for field, prop in self._properties.items():
    if field == 'class':
    continue
    for class_, field_type in SEARCHABLE_PROPERTY_TYPES.items():
    if isinstance(prop, class_):
    searchable_fields.append(field)
    else:
    searchable_fields = self.searchable_fields

    for f in set(searchable_fields):
    prop = self._properties[f]
    value = getattr(self, f)
    field = None
    field_found = False
    for class_, field_type in SEARCHABLE_PROPERTY_TYPES.items():
    if isinstance(prop, class_):
    field_found = True
    if value is not None:
    if isinstance(value, list) or isinstance(value, tuple) or isinstance(value, set):
    for v in value:
    field = field_type(name=f, value=v)
    elif isinstance(value, ndb.Key):
    field = field_type(name=f, value=value.urlsafe())
    elif isinstance(value, bytes):
    field = field_type(name=f, value=int(value))
    else:
    field = field_type(name=f, value=value)
    if not field_found:
    raise ValueError('Cannot find field type for %r on %r' % (prop, self.__class__))

    if field is not None:
    fields.append(field)

    document = search.Document(doc_id, fields=fields)
    index.put(document)


    When using this we seem to get errors like this now inside the Python 3 environment.

    2025-05-16 19:40:50 sync[20250516t153825] assert stub, 'No api proxy found for service "%s"' % service
    2025-05-16 19:40:50 sync[20250516t153825] ^^^^
    2025-05-16 19:40:51 sync[20250516t153825] AssertionError: No api proxy found for service "search"


    Should I expect to be able to use that api in the python 3 environment?

    It looks like some form of middleware was developed for areas like ndb in python 2? I do not know if something similar was done for search.

    Is this considered a layered reverse proxy?

    Continue reading...

Compartilhe esta Página