def create_publisher(): """ Create a publisher for TwillTest, with session management added on. """ session_manager = SessionManager(session_class=AlwaysSession) return Publisher(TwillTest(), session_manager=session_manager)
def create_publisher(coordinator, pubsubhubbub_server=None): push_list = [] if pubsubhubbub_server: push_list.append(pubsubhubbub_server) qx_app = QuixoteWebApp(coordinator, push_list) # sets global Quixote publisher Publisher(qx_app, display_exceptions='plain') # return a WSGI wrapper for the Quixote Web app. return quixote.get_wsgi_app()
def test_config_for_application_json_support(self): pub = Publisher('__main__') self.assertFalse(pub.config.support_application_json) req = pub.create_request(StringIO(), {'CONTENT_TYPE': "application/json"}) self.assertFalse(isinstance(req, HTTPJSONRequest)) pub.configure(SUPPORT_APPLICATION_JSON=1) req = pub.create_request(StringIO(), {'CONTENT_TYPE': "application/json"}) self.assertTrue(isinstance(req, HTTPJSONRequest))
def create_durus_publisher(): global connection filename = os.path.join(tempfile.gettempdir(), 'quixote-demo.durus') print('Opening %r as a Durus database.' % filename) connection = Connection(FileStorage(filename)) root = connection.get_root() session_manager = root.get('session_manager', None) if session_manager is None: session_manager = PersistentSessionManager() connection.get_root()['session_manager'] = session_manager connection.commit() return Publisher(RootDirectory(), session_manager=session_manager, display_exceptions='plain')
def main(): from quixote import enable_ptl enable_ptl() if len(sys.argv) == 2: port = int(sys.argv[1]) else: port = 8080 print 'Now serving the Quixote demo on port %d' % port server = http_server.http_server('', port) publisher = Publisher('quixote.demo') # When initializing the Publisher in your own driver script, # you'll want to parse a configuration file. ##publisher.read_config("/full/path/to/demo.conf") publisher.setup_logs() dh = QuixoteHandler(publisher, 'Quixote/demo', server) server.install_handler(dh) asyncore.loop()
def create_publisher(): return Publisher(RootDirectory(), session_manager=SessionManager(session_class=DemoSession), display_exceptions='plain')
def create_publisher(): return Publisher(RootDirectory(), display_exceptions='plain')
def create_publisher(): from quixote.demo.root import RootDirectory return Publisher(RootDirectory(), display_exceptions='plain')
def create_publisher(): return Publisher(RootDirectory(), error_log="/logs/%s_err.log" % pname, access_log="/logs/%s_acc.log" % pname, display_exceptions="plain")
def create_publisher(): "Create & return a test publisher entry" p = Publisher(TestServer()) p.is_thread_safe = True return p
def selector(songs): global player, song chosen = get_field("select") if chosen: song = chosen player = play(song) redirect("stopper") # works with Mozilla, but not with lynx/elinks else: f = Form() f.add_single_select("select", options=songs) f.add_submit("play", "Play!") return f.render() def stopper(): stop = get_field("stop") if stop: player.kill() return simplepage(body = "%s stopped." % song) else: f = Form() f.add_submit("stop", "Stop") return simplepage(body= ("Playing %s" % song) + f.render()) top.stopper = lambda : stopper() if __name__ == '__main__': print 'Listening on http://localhost:8080 ...' run(lambda : Publisher(top), '', 8080)
def download(self, fname): self.out.write("BEGIN %s" % fname) for line in file(fname): time.sleep(.1) self.out.write(".") yield None self.out.write(" END %s\n" % fname) def quit(self, fd): self.lc.stop() reactor.callLater(1, self.stop) # shutdown in 1 second return "shutdown in 1 second ..." def stop(self): self.out.close() reactor.stop() class Home(Directory): _q_exports = ["micheles", "pippo"] micheles = Interaction() # in principle reserved to user micheles pippo = Interaction() # in principle reserved to user pippo if __name__ == '__main__': from quixote.server import twisted_server c = Controller('localhost', 7080, twisted_server.run) reactor.callLater(1, c.open_browser, "micheles/downloader") c.run(lambda: Publisher(Home()))
def factory(): return Publisher(MySite())