Example #1
0
	def __init__(self, mainSocketPort):
		BetterResource.__init__(self)

		self.putChild('DisplayConnections', DisplayConnections())
		self.putChild('SimpleResponse', SimpleResponse())
		self.putChild('UnicodeRainbow', UnicodeRainbow())
		self.putChild('NoOriginHeader', NoOriginHeader())
		self.putChild('GetEndpointInfo', GetEndpointInfo(mainSocketPort))
Example #2
0
    def __init__(self, fileCache, mainSocketPort, domain, responseCacheOptions):
        BetterResource.__init__(self)

        self.putChild(
            "",
            MinervaBootstrap(
                fileCache, self.templateFile, dict(domain=domain, mainSocketPort=mainSocketPort, **self.dictionary)
            ),
        )
Example #3
0
	def __init__(self, mainSocketPort):
		import jinja2

		BetterResource.__init__(self)

		self._mainSocketPort = mainSocketPort
		self._jinja2Env = jinja2.Environment()
		self._basePath = FilePath(__file__).parent() # this is minerva/dumbtest/
		
		self._fileName = 'dumbtest.html'
Example #4
0
	def __init__(self, fileCache, templateFile, dictionary):
		"""
		C{fileCache} is a L{webmagic.filecache.FileCache}.
		C{templateFile} is a L{FilePath} representing the jinja2 template to
			use.  The latest file contents are cached forever, even if you
			delete your references to the L{MinervaBootstrap}.
		C{dictionary} is a C{dict} whose keys are passed to the template.
			If this is mutated, new requests will have the new dictionary
			contents.
		"""
		BetterResource.__init__(self)
		self._fileCache = fileCache
		self._templateFile = templateFile
		self._dictionary = dictionary
Example #5
0
	def __init__(self, webPort, fileCache, mainSocketPort, domain, closureLibrary):
		import coreweb
		import minerva
		import demosminerva

		import js_coreweb
		import js_minerva
		import js_demosminerva

		BetterResource.__init__(self)

		# Cache for just two days so that corrupt cached copies don't break
		# users for a long time.
		responseCacheOptions = ResponseCacheOptions(
			cacheTime=60*60*24*2,
			httpCachePublic=False,
			httpsCachePublic=True)

		minervaPath = FilePath(minerva.__path__[0])
		demosminervaPath = FilePath(demosminerva.__path__[0])
		self.putChild('', BetterFile(demosminervaPath.child('index.html').path))
		self.putChild('closure-library', BetterFile(closureLibrary.path))
		self.putChild('js_coreweb', BetterFile(FilePath(js_coreweb.__file__).parent().path))
		self.putChild('js_minerva', BetterFile(FilePath(js_minerva.__file__).parent().path))
		self.putChild('js_demosminerva', BetterFile(FilePath(js_demosminerva.__file__).parent().path))
		self.putChild('compiled_client', BetterFile(
			minervaPath.child('compiled_client').path,
			responseCacheOptions=responseCacheOptions))

		# testres_Coreweb always needed for running tests.
		testres_Coreweb = FilePath(coreweb.__path__[0]).child('testres').path
		self.putChild('@testres_Coreweb', BetterFile(testres_Coreweb))

		self.putChild('demosminerva_static', BetterFile(
			FilePath(__file__).sibling('static').path,
			fileCache=fileCache,
			rewriteCss=True,
			responseCacheOptions=responseCacheOptions))
		self.putChild('goog-images', BetterFile(
			FilePath(googstyle.__file__).sibling('goog-images').path,
			responseCacheOptions=responseCacheOptions))
		self.putChild('_minerva', webPort)
		commonArgs = (fileCache, mainSocketPort, domain, responseCacheOptions)
		self.putChild('whiteboard', WhiteboardResource(*commonArgs))
		self.putChild('whiteboard_dev', WhiteboardDevResource(*commonArgs))
		self.putChild('livejournal-stream', LjStreamResource(*commonArgs))
		self.putChild('livejournal-stream_dev', LjStreamDevResource(*commonArgs))
Example #6
0
class DynamicBetterResource(BetterResource):
	path = None
	childResource = BetterResource()

	def getChild(self, path, request):
		self.path = path
		self.request = request
		return self.childResource
Example #7
0
	def __init__(self, reactor, webPort, fileCache, mainSocketPort, domain, closureLibrary):
		import coreweb
		import minerva

		import js_minerva
		import js_coreweb

		BetterResource.__init__(self)

		self._reactor = reactor

		minervaPath = FilePath(minerva.__path__[0])
		self.putChild('', BetterFile(minervaPath.child('index.html').path))

		self.putChild('closure-library', BetterFile(closureLibrary.path))
		self.putChild('js_coreweb', BetterFile(FilePath(js_coreweb.__file__).parent().path))
		self.putChild('js_minerva', BetterFile(FilePath(js_minerva.__file__).parent().path))
		self.putChild('compiled_client', BetterFile(minervaPath.child('compiled_client').path))

		# testres_Coreweb always needed for running tests.
		testres_Coreweb = FilePath(coreweb.__path__[0]).child('testres').path
		self.putChild('@testres_Coreweb', BetterFile(testres_Coreweb))

		testres_Minerva = ResourcesForTest(mainSocketPort)
		self.putChild('@testres_Minerva', testres_Minerva)

		# Also used by tests
		self.putChild('_minerva', webPort)

		self.putChild('js_minerva_tests.html', BetterFile(
			minervaPath.child('js_minerva_tests.html').path))

		self.putChild('dumbtest', DumbTestPage(mainSocketPort))
		self.putChild('chatapp', ChatAppPage(fileCache, domain, mainSocketPort))

		# Used by chatapp
		self.putChild('wait_resource', WaitResource(clock=reactor))

		# The docs are outside of the minerva package
		docsDir = FilePath(__file__).parent().sibling('docs')
		if docsDir.exists():
			self.putChild('docs', BetterFile(docsDir.path))

		self.putChild('form_sandbox', FormSandbox(self._reactor))
Example #8
0
	def test_noDelayFalse(self):
		"""
		If noDelay=False is passed to BetterSite, it does not set NO_DELAY
		on new connections, leaving the default option.
		"""
		br = BetterResource()
		bs = BetterSite(br, noDelay=False)
		channel = bs.buildProtocol(None)
		transport = DummyTCPTransport()
		channel.makeConnection(transport)
		self.assertFalse(transport.everCalledSetTcpNoDelay())

		# Lose the connection to clear HTTPChannel.timeOut, so we don't
		# have a dirty reactor.
		channel.connectionLost(None)
Example #9
0
	def test_noDelayTrue(self):
		"""
		The default options for BetterSite cause NO_DELAY to be set to True
		on new connections.
		"""
		br = BetterResource()
		bs = BetterSite(br)
		channel = bs.buildProtocol(None)
		transport = DummyTCPTransport()
		channel.makeConnection(transport)
		self.assertTrue(transport.everCalledSetTcpNoDelay())
		self.assertTrue(transport.getTcpNoDelay())

		# Lose the connection to clear HTTPChannel.timeOut, so we don't
		# have a dirty reactor.
		channel.connectionLost(None)
Example #10
0
	def __init__(self, fileCache, domain, mainSocketPort):
		BetterResource.__init__(self)

		templateFile = FilePath(__file__).sibling('chatapp.html')
		self.putChild('', MinervaBootstrap(fileCache, templateFile,
			dict(domain=domain, dev_mode=True, mainSocketPort=mainSocketPort)))
Example #11
0
	def __init__(self, mainSocketPort):
		BetterResource.__init__(self)

		self.putChild('', Index(mainSocketPort))
		self.putChild('app.swf', static.File(FilePath(__file__).sibling('app.swf').path))
Example #12
0
	def __init__(self):
		BetterResource.__init__(self)
		index = Leaf()
		self.putChild('', index)
Example #13
0
	def __init__(self):
		BetterResource.__init__(self)
		child = Leaf()
		self.putChild('child', child)
Example #14
0
	def __init__(self, mainSocketPort):
		BetterResource.__init__(self)
		self._mainSocketPort = mainSocketPort
Example #15
0
	def __init__(self, reactor):
		BetterResource.__init__(self)
		self._reactor = reactor
Example #16
0
    def __init__(
        self, webPort, fileCache, mainSocketPort, domain, closureLibrary
    ):

        BetterResource.__init__(self)
Example #17
0
    def __init__(self, webPort, fileCache, mainSocketPort, domain,
                 closureLibrary):

        BetterResource.__init__(self)
Example #18
0
	def __init__(self):
		BetterResource.__init__(self)
		index = NonLeafWithIndexChild()
		self.putChild('', index)