diff --git a/direct/src/distributed/AsyncRequest.py b/direct/src/distributed/AsyncRequest.py index 2cc951e444..f909066af7 100755 --- a/direct/src/distributed/AsyncRequest.py +++ b/direct/src/distributed/AsyncRequest.py @@ -200,6 +200,12 @@ class AsyncRequest(DirectObject): """ Create a new database object. You can get the doId from within your self.finish() function. + + This functions is different from createObjectId in that it does + generate the object when the response comes back. The object is + added to the doId2do and so forth and treated as a full regular + object (which it is). This is useful on the AI where we really + do want the object on the AI. """ assert self.notify.debugCall() assert not self.__deleted @@ -208,15 +214,41 @@ class AsyncRequest(DirectObject): self.neededObjects[name]=None if context is None: context=self.air.allocateContext() - newDBRequestGen = config.GetBool( #HACK: - 'new-database-request-generate', 1) - if newDBRequestGen: - self.accept( - self.air.getDatabaseGenerateResponseEvent(context), - self._doCreateObject, [name, className, values]) - else: - self.accept( - "doRequestResponse-%s"%(context,), self._checkCompletion, [name]) + self.accept( + self.air.getDatabaseGenerateResponseEvent(context), + self._doCreateObject, [name, className, values]) + ## newDBRequestGen = config.GetBool( #HACK: + ## 'new-database-request-generate', 1) + ## if newDBRequestGen: + ## self.accept( + ## self.air.getDatabaseGenerateResponseEvent(context), + ## self._doCreateObject, [name, className, values]) + ## else: + ## self.accept( + ## "doRequestResponse-%s"%(context,), self._checkCompletion, [name]) + self.air.requestDatabaseGenerate(className, context, values=values) + + def createObjectId(self, name, className, context=None, values=None): + """ + Create a new database object. You can get the doId from within + your self.finish() function. + + This functions is different from createObject in that it does not + generate the object when the response comes back. It only tells you + the doId. This is useful on the UD where we don't really want the + object on the UD, we just want the object created and the UD wants + to send messages to it using the ID. + """ + assert self.notify.debugCall() + assert not self.__deleted + assert name + assert className + self.neededObjects[name]=None + if context is None: + context=self.air.allocateContext() + self.accept( + self.air.getDatabaseGenerateResponseEvent(context), + self._checkCompletion, [name]) self.air.requestDatabaseGenerate(className, context, values=values) def _doCreateObject(self, name, className, values, doId):