コード例 #1
0
    def initialize(self):
        self._param_extractor = ParamExtractor(self)
        self._path_extractor = PathExtractor(self)
        self._body_extractor = BodyExtractor(self)

        self.context_data = data.ContextData()
        self.context_data.open_connection()
        self.feedback_data = data.FeedbackData()
        self.feedback_data.open_connection()
コード例 #2
0
    def initialize(self, contextualizer: Contextualizer):
        self._param_extractor = ParamExtractor(self)
        self._path_extractor = PathExtractor(self)
        self._body_extractor = BodyExtractor(self)

        self.context_data = data.ContextData()
        self.context_data.open_connection()
        self.contextualizer = contextualizer
        self.message_data = data.MessageData()
        self.message_data.open_connection()
コード例 #3
0
ファイル: messages.py プロジェクト: rdefeo/context
class Message(RequestHandler):
    context_data = None
    message_data = None
    contextualizer = None
    _param_extractor = None
    _path_extractor = None
    _body_extractor = None

    def data_received(self, chunk):
        pass

    def initialize(self, contextualizer: Contextualizer):
        self._param_extractor = ParamExtractor(self)
        self._path_extractor = PathExtractor(self)
        self._body_extractor = BodyExtractor(self)

        self.context_data = data.ContextData()
        self.context_data.open_connection()
        self.contextualizer = contextualizer
        self.message_data = data.MessageData()
        self.message_data.open_connection()

    def on_finish(self):
        pass

    @asynchronous
    @engine
    def post(self, context_id, *args, **kwargs):
        message = self.message_data.insert(
            self._path_extractor.context_id(context_id),
            self._body_extractor.direction(),
            self._body_extractor.text(),
            detection=self._body_extractor.detection(),
            now=self._body_extractor.created()
        )

        _rev = message["_id"]
        self.contextualizer.update(
            self._path_extractor.context_id(context_id),
            _rev,
            [message]
        )

        self.set_status(201)
        self.set_header("Location", "/%s/messages/%s" % (context_id, message["_id"]))
        self.set_header("_id", str(message["_id"]))
        self.set_header("_rev", str(_rev))
        self.finish()
コード例 #4
0
    def initialize(self):
        self.message_data = data.MessageData()
        self.message_data.open_connection()

        self.param_extractor = ParamExtractor(self)
        self.path_extractor = PathExtractor(self)
        self.body_extractor = BodyExtractor(self)
コード例 #5
0
class Message(RequestHandler):
    context_data = None
    message_data = None
    contextualizer = None
    _param_extractor = None
    _path_extractor = None
    _body_extractor = None

    def data_received(self, chunk):
        pass

    def initialize(self, contextualizer: Contextualizer):
        self._param_extractor = ParamExtractor(self)
        self._path_extractor = PathExtractor(self)
        self._body_extractor = BodyExtractor(self)

        self.context_data = data.ContextData()
        self.context_data.open_connection()
        self.contextualizer = contextualizer
        self.message_data = data.MessageData()
        self.message_data.open_connection()

    def on_finish(self):
        pass

    @asynchronous
    @engine
    def post(self, context_id, *args, **kwargs):
        message = self.message_data.insert(
            self._path_extractor.context_id(context_id),
            self._body_extractor.direction(),
            self._body_extractor.text(),
            detection=self._body_extractor.detection(),
            now=self._body_extractor.created())

        _rev = message["_id"]
        self.contextualizer.update(self._path_extractor.context_id(context_id),
                                   _rev, [message])

        self.set_status(201)
        self.set_header("Location",
                        "/%s/messages/%s" % (context_id, message["_id"]))
        self.set_header("_id", str(message["_id"]))
        self.set_header("_rev", str(_rev))
        self.finish()
コード例 #6
0
ファイル: feedback.py プロジェクト: rdefeo/context
    def initialize(self):
        self._param_extractor = ParamExtractor(self)
        self._path_extractor = PathExtractor(self)
        self._body_extractor = BodyExtractor(self)

        self.context_data = data.ContextData()
        self.context_data.open_connection()
        self.feedback_data = data.FeedbackData()
        self.feedback_data.open_connection()
コード例 #7
0
ファイル: messages.py プロジェクト: rdefeo/context
    def initialize(self, contextualizer: Contextualizer):
        self._param_extractor = ParamExtractor(self)
        self._path_extractor = PathExtractor(self)
        self._body_extractor = BodyExtractor(self)

        self.context_data = data.ContextData()
        self.context_data.open_connection()
        self.contextualizer = contextualizer
        self.message_data = data.MessageData()
        self.message_data.open_connection()
コード例 #8
0
class Feedback(RequestHandler):
    context_data = None
    feedback_data = None

    _param_extractor = None
    _path_extractor = None
    _body_extractor = None

    def data_received(self, chunk):
        pass

    def initialize(self):
        self._param_extractor = ParamExtractor(self)
        self._path_extractor = PathExtractor(self)
        self._body_extractor = BodyExtractor(self)

        self.context_data = data.ContextData()
        self.context_data.open_connection()
        self.feedback_data = data.FeedbackData()
        self.feedback_data.open_connection()

    def on_finish(self):
        pass

    @asynchronous
    @engine
    def post(self, context_id, *args, **kwargs):
        self.set_header('Content-Type', 'application/json')

        inserted_feedback = self.feedback_data.insert(
            self._param_extractor.user_id(),
            self._param_extractor.application_id(),
            self._param_extractor.session_id(),
            self._path_extractor.context_id(context_id),
            self._param_extractor.product_id(), self._param_extractor.type(),
            self._body_extractor.meta_data())

        _rev = inserted_feedback["_id"]

        self.set_status(201)
        self.set_header(
            "Location",
            "/%s/feedback/%s" % (context_id, inserted_feedback["_id"]))
        self.set_header("_id", str(inserted_feedback["_id"]))
        self.set_header("_rev", str(_rev))
        self.finish()
コード例 #9
0
ファイル: feedback.py プロジェクト: rdefeo/context
class Feedback(RequestHandler):
    context_data = None
    feedback_data = None

    _param_extractor = None
    _path_extractor = None
    _body_extractor = None

    def data_received(self, chunk):
        pass

    def initialize(self):
        self._param_extractor = ParamExtractor(self)
        self._path_extractor = PathExtractor(self)
        self._body_extractor = BodyExtractor(self)

        self.context_data = data.ContextData()
        self.context_data.open_connection()
        self.feedback_data = data.FeedbackData()
        self.feedback_data.open_connection()

    def on_finish(self):
        pass

    @asynchronous
    @engine
    def post(self, context_id, *args, **kwargs):
        self.set_header('Content-Type', 'application/json')

        inserted_feedback = self.feedback_data.insert(
            self._param_extractor.user_id(),
            self._param_extractor.application_id(),
            self._param_extractor.session_id(),
            self._path_extractor.context_id(context_id),
            self._param_extractor.product_id(),
            self._param_extractor.type(),
            self._body_extractor.meta_data()
        )

        _rev = inserted_feedback["_id"]

        self.set_status(201)
        self.set_header("Location", "/%s/feedback/%s" % (context_id, inserted_feedback["_id"]))
        self.set_header("_id", str(inserted_feedback["_id"]))
        self.set_header("_rev", str(_rev))
        self.finish()