In order to respond to an AJAX query, we define matching domain service methods that look up requested values. Also needed are the corresponding view methods to call the domain service methods and produce JSON responses. Accordingly, in booksomeplace.domain.partner.PartnerService we define a method called fetchByPartnerKey() that retrieves a list of property keys and names:
def fetchByPartnerKey(self, key) :
query = {'partnerKey' : key}
proj = {'propertyKey' : 1, 'propName' : 1, '_id' : 0}
result = self.collection.find(query, proj)
data = []
if result :
for doc in result :
data.append(doc)
return data
The other method needed is fetchContactInfoByKey(), called when a property has been selected. Again we use the projection argument to limit the information returned to the embedded object's Name, represented by contactName, and Contact...