示例#1
0
    def installSite(self, siteStore, domain, publicURL, generateCert=True):
        """
        Create the necessary items to run an HTTP server and an SSH server.
        """
        certPath = siteStore.filesdir.child("server.pem")
        if generateCert and not certPath.exists():
            certPath.setContent(self._createCert(domain, genSerial()))

        # Install the base Mantissa offering.
        IOfferingTechnician(siteStore).installOffering(baseOffering)

        # Make the HTTP server baseOffering includes listen somewhere.
        site = siteStore.findUnique(SiteConfiguration)
        site.hostname = domain
        installOn(TCPPort(store=siteStore, factory=site, portNumber=8080),
                  siteStore)
        installOn(
            SSLPort(store=siteStore,
                    factory=site,
                    portNumber=8443,
                    certificatePath=certPath), siteStore)

        # Make the SSH server baseOffering includes listen somewhere.
        shell = siteStore.findUnique(SecureShellConfiguration)
        installOn(TCPPort(store=siteStore, factory=shell, portNumber=8022),
                  siteStore)

        # Install a front page on the top level store so that the
        # developer will have something to look at when they start up
        # the server.
        fp = siteStore.findOrCreate(publicweb.FrontPage, prefixURL=u'')
        installOn(fp, siteStore)
示例#2
0
    def test_baseOffering(self):
        """
        L{Mantissa.installSite} installs the Mantissa base offering.
        """
        options = Mantissa()
        options.installSite(self.siteStore, u"example.com", u"", False)

        self.assertEqual(
            IOfferingTechnician(self.siteStore).getInstalledOfferingNames(),
            [baseOffering.name])
示例#3
0
    def child_static(self, context):
        """
        Serve a container page for static content for Mantissa and other
        offerings.
        """
        offeringTech = IOfferingTechnician(self.siteStore)
        installedOfferings = offeringTech.getInstalledOfferings()
        offeringsWithContent = dict([
                (offering.name, offering.staticContentPath)
                for offering
                in installedOfferings.itervalues()
                if offering.staticContentPath])

        # If you wanted to do CSS rewriting for all CSS files served beneath
        # /static/, you could do it by passing a processor for ".css" here.
        # eg:
        #
        # website = IResource(self.store)
        # factory = StylesheetFactory(
        #     offeringsWithContent.keys(), website.rootURL)
        # StaticContent(offeringsWithContent, {
        #               ".css": factory.makeStylesheetResource})
        return StaticContent(offeringsWithContent, {})
示例#4
0
    def setUpMailStuff(self, extraPowerups=(), dbdir=None, generateCert=False):
        filesdir = None
        if dbdir is None:
            filesdir = self.mktemp()
        self.siteStore = store.Store(dbdir=dbdir, filesdir=filesdir)
        Mantissa().installSite(self.siteStore, u"example.com", u"", generateCert)
        IOfferingTechnician(self.siteStore).installOffering(quotientOffering)

        loginSystem = self.siteStore.findUnique(LoginSystem)
        account = loginSystem.addAccount(u'testuser', u'example.com', None)
        self.substore = account.avatars.open()

        product = Product(
            store=self.siteStore,
            types=[qual(Inbox)] + map(qual, extraPowerups))
        product.installProductOn(self.substore)

        self.deliveryAgent = self.substore.findUnique(DeliveryAgent)
        return self.createMIMEReceiver()
示例#5
0
 def setUp(self):
     self.siteStore = Store(self.mktemp())
     installOn(LoginSystem(store=self.siteStore), self.siteStore)
     offering = entropyoff.plugin
     IOfferingTechnician(self.siteStore).installOffering(offering)