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(): certcreate.main([ '--filename', certPath.path, '--quiet', '--serial-number', str(genSerial()), '--hostname', domain ]) # 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)
def createStore(testCase): """ Create a new Store in a temporary directory retrieved from C{testCase}. Give it a LoginSystem and create an SSL certificate in its files directory. @param testCase: The L{unittest.TestCase} by which the returned Store will be used. @rtype: L{Store} """ dbdir = testCase.mktemp() store = Store(dbdir) login = userbase.LoginSystem(store=store) installOn(login, store) certPath = store.newFilePath('server.pem') certcreate.main(['--filename', certPath.path, '--quiet']) return store
def postOptions(self): s = self.parent.getStore() s.findOrCreate(userbase.LoginSystem, lambda i: installOn(i, s)) for ws in s.query(website.WebSite): break else: ws = website.WebSite( store=s, portNumber=8080, securePortNumber=8443, certificateFile='server.pem') installOn(ws, s) if not os.path.exists('server.pem'): certcreate.main([]) #Is there a real way to do this? u = portal.IRealm(s).addAccount(u'confession', self['domain'], u'no password :(') us = u.avatars.open() installOn(confession.AnonConfessionUser(store=us), us) installOn(confession.ConfessionDispatcher(store=us, localHost=self['domain']), us)
def postOptions(self): s = self.parent.getStore() s.findOrCreate(userbase.LoginSystem, lambda i: installOn(i, s)) for ws in s.query(website.WebSite): break else: ws = website.WebSite(store=s, portNumber=8080, securePortNumber=8443, certificateFile='server.pem') installOn(ws, s) if not os.path.exists('server.pem'): certcreate.main([]) #Is there a real way to do this? u = portal.IRealm(s).addAccount(u'confession', self['domain'], u'no password :(') us = u.avatars.open() installOn(confession.AnonConfessionUser(store=us), us) installOn( confession.ConfessionDispatcher(store=us, localHost=self['domain']), us)
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(): certcreate.main([ '--filename', certPath.path, '--quiet', '--serial-number', str(genSerial()), '--hostname', domain]) # 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)