Exemplo n.º 1
0
    def __call__(self, req_env, start_response, wsgi_url=None):
        '''This method conforms to the WSGI spec for callable wsgi applications
        (PEP 333). It looks in environ['wsgi.input'] for a fully formed rpc
        message envelope, will deserialize the request parameters and call the
        method on the object returned by the get_handler() method.
        '''

        url = wsgi_url
        verb = req_env['REQUEST_METHOD'].upper()
        if url is None:
            url = reconstruct_url(req_env).split('.wsdl')[0]

        if self.__is_wsdl_request(req_env):
            return self.__handle_wsdl_request(req_env, start_response, url)

        elif not (self._allowed_http_verbs is None or verb
                  in self._allowed_http_verbs or verb in self._verb_handlers):
            start_response(HTTP_405, [
                ('Content-Type', ''),
                ('Allow', ', '.join(self._allowed_http_verbs)),
            ])
            return [HTTP_405]

        else:
            return self._verb_handlers[verb](req_env, start_response)
Exemplo n.º 2
0
    def __call__(self, req_env, start_response, wsgi_url=None):
        '''This method conforms to the WSGI spec for callable wsgi applications
        (PEP 333). It looks in environ['wsgi.input'] for a fully formed rpc
        message envelope, will deserialize the request parameters and call the
        method on the object returned by the get_handler() method.
        '''

        url = wsgi_url
        verb = req_env['REQUEST_METHOD'].upper()
        if url is None:
            url = reconstruct_url(req_env).split('.wsdl')[0]

        if self.__is_wsdl_request(req_env):
            return self.__handle_wsdl_request(req_env, start_response, url)

        elif not (self._allowed_http_verbs is None or
               verb in self._allowed_http_verbs or verb in self._verb_handlers):
            start_response(HTTP_405, [
                ('Content-Type', ''),
                ('Allow', ', '.join(self._allowed_http_verbs)),
            ])
            return [HTTP_405]

        else:
            return self._verb_handlers[verb](req_env, start_response)
Exemplo n.º 3
0
    def download_html(ctx, project_name, version):
        ctx.transport.mime_type = "text/html"
        own_url = reconstruct_url(ctx.transport.req_env,
                                  path=False,
                                  query_string=False)
        try:
            ctx.udc.session.query(Package).filter_by(
                package_name=project_name).one()
        except NoResultFound:
            cache_package(project_name, own_url)

        download = HtmlPage(TPL_DOWNLOAD)
        download.title = project_name
        if version:
            release = ctx.udc.session.query(Release).join(Package).filter(
                sql.and_(
                    Package.package_name == project_name,
                    Release.release_version == version,
                )).one()

            if len(release.distributions) == 0:
                cache_package("%s==%s" % (project_name, version), own_url)
                ctx.udc.session.refresh(release)

            download.link.attrib["href"] = "%s/doap.rdf" % (release.rdf_about)
            download.h1 = '%s-%s' % (project_name, version)
            download.a = release.distributions[0].file_name
            download.a.attrib["href"] = "/files/%s/%s#md5=%s" % (
                release.distributions[0].file_path,
                release.distributions[0].file_name,
                release.distributions[0].dist_md5,
            )

        else:
            package = ctx.udc.session.query(Package) \
                                     .filter_by(package_name=project_name).one()

            if len(package.latest_release.distributions) == 0:
                cache_package(project_name, own_url)
                ctx.udc.session.refresh(package)

            download = HtmlPage(TPL_DOWNLOAD)
            download.link.attrib["href"] = '%s/doap.rdf' % (
                package.latest_release.rdf_about)
            download.h1 = project_name
            download.a = package.latest_release.distributions[0].file_name
            download.a.attrib["href"] = "/files/%s/%s#md5=%s" % (
                package.latest_release.distributions[0].file_path,
                package.latest_release.distributions[0].file_name,
                package.latest_release.distributions[0].dist_md5)

        return html.tostring(download.html)
Exemplo n.º 4
0
    def download_html(ctx, project_name, version):
        ctx.transport.mime_type = "text/html"
        own_url = reconstruct_url(ctx.transport.req_env,
                                                 path=False, query_string=False)
        try:
            ctx.udc.session.query(Package).filter_by(
                                                package_name=project_name).one()
        except NoResultFound:
            cache_package(project_name, own_url)

        download = HtmlPage(TPL_DOWNLOAD)
        download.title = project_name
        if version:
            release = ctx.udc.session.query(Release).join(Package).filter(
                sql.and_(
                    Package.package_name == project_name,
                    Release.release_version == version,
                )).one()

            if len(release.distributions) == 0:
                cache_package("%s==%s" % (project_name, version), own_url)
                ctx.udc.session.refresh(release)

            download.link.attrib["href"] = "%s/doap.rdf" % (release.rdf_about)
            download.h1 = '%s-%s' % (project_name, version)
            download.a = release.distributions[0].file_name
            download.a.attrib["href"] = "/files/%s/%s#md5=%s" % (
                    release.distributions[0].file_path,
                    release.distributions[0].file_name,
                    release.distributions[0].dist_md5,
                )

        else:
            package = ctx.udc.session.query(Package) \
                                     .filter_by(package_name=project_name).one()

            if len(package.latest_release.distributions) == 0:
                cache_package(project_name, own_url)
                ctx.udc.session.refresh(package)

            download = HtmlPage(TPL_DOWNLOAD)
            download.link.attrib["href"] = '%s/doap.rdf' % (package.latest_release.rdf_about)
            download.h1 = project_name
            download.a = package.latest_release.distributions[0].file_name
            download.a.attrib["href"] = "/files/%s/%s#md5=%s" % (
                    package.latest_release.distributions[0].file_path,
                    package.latest_release.distributions[0].file_name,
                    package.latest_release.distributions[0].dist_md5
                )

        return html.tostring(download.html)
Exemplo n.º 5
0
    def __call__(self, req_env, start_response, wsgi_url=None):
        '''This method conforms to the WSGI spec for callable wsgi applications
        (PEP 333). It looks in environ['wsgi.input'] for a fully formed rpc
        message envelope, will deserialize the request parameters and call the
        method on the object returned by the get_handler() method.
        '''

        url = wsgi_url
        if url is None:
            url = reconstruct_url(req_env).split('.wsdl')[0]

        if self.__is_wsdl_request(req_env):
            return self.__handle_wsdl_request(req_env, start_response, url)

        else:
            return self.handle_rpc(req_env, start_response)
Exemplo n.º 6
0
    def __call__(self, req_env, start_response, wsgi_url=None):
        """This method conforms to the WSGI spec for callable wsgi applications
        (PEP 333). It looks in environ['wsgi.input'] for a fully formed rpc
        message envelope, will deserialize the request parameters and call the
        method on the object returned by the get_handler() method.
        """

        url = wsgi_url
        if url is None:
            url = reconstruct_url(req_env).split('.wsdl')[0]

        if self.is_wsdl_request(req_env):
            return self.handle_wsdl_request(req_env, start_response, url)

        else:
            return self.handle_rpc(req_env, start_response)