コード例 #1
0
 def initialize(self, contextualizer: Contextualizer):
     self.contextualizer = contextualizer
     from context.data.context import Context
     self.context_data = Context()
     self.context_data.open_connection()
     self.param_extractor = ParamExtractor(self)
     self.path_extractor = PathExtractor(self)
コード例 #2
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()
コード例 #3
0
ファイル: context.py プロジェクト: rdefeo/context
class Context(RequestHandler):
    context_data = None
    contextualizer = None
    param_extractor = None
    path_extractor = None

    def initialize(self, contextualizer: Contextualizer):
        self.contextualizer = contextualizer
        from context.data.context import Context
        self.context_data = Context()
        self.context_data.open_connection()
        self.param_extractor = ParamExtractor(self)
        self.path_extractor = PathExtractor(self)

    def data_received(self, chunk):
        pass

    def on_finish(self):
        pass

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

        # hours = 600
        # self.set_header('Cache-Control', 'public,max-age=%d' % int(3600*hours))
        self.finish(
            dumps(
                self.context_data.get(self.path_extractor.context_id(context_id), self.param_extractor.rev())
            )
        )

    @asynchronous
    def post(self, *args, **kwargs):
        new_context_id = ObjectId()
        self.contextualizer.create(
            new_context_id,
            self.param_extractor.user_id(),
            self.param_extractor.application_id(),
            self.param_extractor.session_id(),
            self.param_extractor.locale()
        )

        self.set_header('Content-Type', 'application/json')
        self.add_header("Location", "/%s" % str(new_context_id))
        self.add_header("_id", str(new_context_id))
        self.add_header("_rev", str(new_context_id))
        self.set_status(201)
        self.finish()
コード例 #4
0
class Context(RequestHandler):
    context_data = None
    contextualizer = None
    param_extractor = None
    path_extractor = None

    def initialize(self, contextualizer: Contextualizer):
        self.contextualizer = contextualizer
        from context.data.context import Context
        self.context_data = Context()
        self.context_data.open_connection()
        self.param_extractor = ParamExtractor(self)
        self.path_extractor = PathExtractor(self)

    def data_received(self, chunk):
        pass

    def on_finish(self):
        pass

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

        # hours = 600
        # self.set_header('Cache-Control', 'public,max-age=%d' % int(3600*hours))
        self.finish(
            dumps(
                self.context_data.get(
                    self.path_extractor.context_id(context_id),
                    self.param_extractor.rev())))

    @asynchronous
    def post(self, *args, **kwargs):
        new_context_id = ObjectId()
        self.contextualizer.create(new_context_id,
                                   self.param_extractor.user_id(),
                                   self.param_extractor.application_id(),
                                   self.param_extractor.session_id(),
                                   self.param_extractor.locale())

        self.set_header('Content-Type', 'application/json')
        self.add_header("Location", "/%s" % str(new_context_id))
        self.add_header("_id", str(new_context_id))
        self.add_header("_rev", str(new_context_id))
        self.set_status(201)
        self.finish()
コード例 #5
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)
コード例 #6
0
ファイル: context.py プロジェクト: rdefeo/context
 def initialize(self, contextualizer: Contextualizer):
     self.contextualizer = contextualizer
     from context.data.context import Context
     self.context_data = Context()
     self.context_data.open_connection()
     self.param_extractor = ParamExtractor(self)
     self.path_extractor = PathExtractor(self)
コード例 #7
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()
コード例 #8
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()
コード例 #9
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()
コード例 #10
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()