I'm using the Python 1.6.6 SDK and having trouble getting the search API to initialise a new Document:
from google.appengine.api import search
def index_document(document_id, some_string):
return search.Document(
doc_id=document_id,
fields=[
search.TextField(name='text_field', value=some_string),
search.DateField(name='date', value=datetime.now().date())
])
In response I get:
AttributeError: type object 'search' has no attribute 'Document'
I can't see any evidence that this is a general problem, and all the docs point to this being the procedure for initialising a Document.
However, if I place the API call within the function it executes as expected:
def index_document(document_id, some_string):
from google.appengine.api import search
return search.Document(...
I can't see any reason why this would work, but a global import wouldn't as I am importing a number of their APIs. Has anyone had a similar problem/success in getting it to work?