def new(self, context_dict): """ @param context_dict: a dictionary containing the expected field of a context, is called and define as contextDescriptionDict @return: context_gus, the universally unique identifier of the context """ log.debug("[D] %s %s " % (__file__, __name__), "Context new", context_dict) store = self.getStore('context new') cntx = Context() cntx.context_gus = idops.random_context_gus() cntx.node_id = 1 cntx.creation_date = gltime.utcDateNow() cntx.update_date = gltime.utcDateNow() cntx.last_activity = gltime.utcDateNow() cntx.receivers = [] try: cntx._import_dict(context_dict) except KeyError: store.rollback() store.close() raise InvalidInputFormat("Import failed near the Storm") store.add(cntx) log.msg("Created context %s at the %s" % (cntx.name, cntx.creation_date) ) store.commit() store.close() # return context_dict return cntx.context_gus
def new(self, context_dict): """ @param context_dict: a dictionary containing the expected field of a context, is called and define as contextDescriptionDict @return: context_gus, the universally unique identifier of the context """ self.context_gus = idops.random_context_gus() self.creation_date = gltime.utcTimeNow() self.update_date = gltime.utcTimeNow() self.last_activity = gltime.utcTimeNow() self.receivers = [] try: self._import_dict(context_dict) except KeyError, e: raise InvalidInputFormat("Context Import failed (missing %s)" % e)