示例#1
0
    def _make_appurl(self, instkey):
        """Compute the base url for application specified by `instkey` which
        is a tuple of,
            ( appsec, mount-type, mount-name, configfile)

        Return the base-url as byte-string.
        """
        port = self.settings["pluggdapps"]["port"]
        scheme = self.settings["pluggdapps"]["scheme"]
        appsec, netpath, config = instkey
        netloc, script = h.parse_netpath(netpath)

        # Prefix scheme
        appurl = scheme + "://" + netloc

        # prefix port
        if port:
            if (scheme, port) in [("http", 80), ("https", 443)]:
                port = ""
            else:
                port = str(port)
            appurl += ":" + port

        # Prefix SCRIPT-NAME, mountname is already prefixed with URLSEP
        appurl += script

        return appurl
    def _make_appurl(self, instkey):
        """Compute the base url for application specified by `instkey` which
        is a tuple of,
            ( appsec, mount-type, mount-name, configfile)

        Return the base-url as byte-string.
        """
        port = self.settings['pluggdapps']['port']
        scheme = self.settings['pluggdapps']['scheme']
        appsec, netpath, config = instkey
        netloc, script = h.parse_netpath(netpath)

        # Prefix scheme
        appurl = scheme + '://' + netloc

        # prefix port
        if port:
            if (scheme, port) in [('http', 80), ('https', 443)]:
                port = ''
            else:
                port = str(port)
            appurl += ':' + port

        # Prefix SCRIPT-NAME, mountname is already prefixed with URLSEP
        appurl += script

        return appurl
示例#3
0
    def boot(cls, baseini, *args, **kwargs):
        """Parse ``[mountloc]`` section for application-wise configuration
        settings and return a fresh instance of :class:`Webapps` class.
        """
        pa = super().boot(baseini, *args, **kwargs)
        pa.webapps = {}
        pa.appurls = {}

        appsettings = pa._mountapps()

        netpaths = [instkey[1] for instkey, appsett in appsettings.items()]
        pa.configdb.dbinit(netpaths=netpaths)

        # Mount webapp instances for subdomains and scripts.
        for instkey, appsett in appsettings.items():
            appsec, netpath, config = instkey

            # Instantiate the IWebAPP plugin here for each `instkey`
            appname = h.sec2plugin(appsec)
            webapp = pa.qp(pa, instkey, IWebApp, appname, appsett)
            webapp.appsettings = appsett
            # Update with backend configuration.
            [webapp.appsettings[section].update(d) for section, d in pa.configdb.config(netpath=netpath).items()]

            webapp.instkey, webapp.netpath = instkey, None
            pa.webapps[instkey] = webapp
            pa.netpaths[netpath] = webapp
            pa.appurls[instkey] = webapp.baseurl = pa._make_appurl(instkey)

            pa._app_resolve_cache[h.parse_netpath(netpath)] = webapp

            # Resolution mapping for web-applications
            webapp.netpath = netpath

        return pa
    def boot(cls, baseini, *args, **kwargs):
        """Parse ``[mountloc]`` section for application-wise configuration
        settings and return a fresh instance of :class:`Webapps` class.
        """
        pa = super().boot(baseini, *args, **kwargs)
        pa.webapps = {}
        pa.appurls = {}

        appsettings = pa._mountapps()

        netpaths = [instkey[1] for instkey, appsett in appsettings.items()]
        pa.configdb.dbinit(netpaths=netpaths)

        # Mount webapp instances for subdomains and scripts.
        for instkey, appsett in appsettings.items():
            appsec, netpath, config = instkey

            # Instantiate the IWebAPP plugin here for each `instkey`
            appname = h.sec2plugin(appsec)
            webapp = pa.qp(pa, instkey, IWebApp, appname, appsett)
            webapp.appsettings = appsett
            # Update with backend configuration.
            [
                webapp.appsettings[section].update(d)
                for section, d in pa.configdb.config(netpath=netpath).items()
            ]

            webapp.instkey, webapp.netpath = instkey, None
            pa.webapps[instkey] = webapp
            pa.netpaths[netpath] = webapp
            pa.appurls[instkey] = webapp.baseurl = pa._make_appurl(instkey)

            pa._app_resolve_cache[h.parse_netpath(netpath)] = webapp

            # Resolution mapping for web-applications
            webapp.netpath = netpath

        return pa