def InstallInWebKit(appServer): ui = UI(verbose=True) schema = Schema() schema.startup(ui) ui.addDatabase(name="luc", conn=Connection("luc.db"), schema=schema, label="Lucs Heimatseite") app = appServer.application() app.lino_ui = ui app.addShutDownHandler(ui.shutdown)
sys.exit(-1) for o, a in opts: if o in ("-?", "-h", "--help"): print __doc__ sys.exit() elif o in ("-o", "--output"): localBasepath = a elif o in ("-b", "--batch"): showOutput = False dbfile = args[0] ui = UI(verbose=True) schema = Schema() schema.startup(ui) conn = Connection(dbfile) #, isTemporary=True) db = ui.addDatabase(None, conn,schema, label="Lino Demo Database") db2html(db,localBasepath,baseuri) url = os.path.join(localBasepath,'index.html') if showOutput: webbrowser.open(url,new=True)
def main(argv): parser = OptionParser() parser.add_option("-v", "--verbose", help="display many messages", action="store_true", dest="verbose", default=True) parser.add_option("-s", "--skip-dbcheck", help="skip integrity check of foreign databases", action="store_true", dest="skipTest", default=False) parser.add_option("-p", "--port", help="alternate PORT where to listen" "(default is 8080)", action="store", dest="port", type="int", default=8080, ) (options, args) = parser.parse_args(argv) del args[0] demoDir = os.path.dirname(__file__) #center.start(verbose=options.verbose) #info = center.getSystemConsole().info from lino.ui.console import info, progress #progress = app.console.progress schema = Schema(big=False) schema.startup() schema.setLayout(sprlwidgets) serverRsc = ServerResource(wwwRoot) #sess = ConsoleSession() sess = center.createSession() if True: """ Shared tables are the same for each database """ info("Starting std.db...") conn = Connection(schema=schema) stddb = Database(langs="en de fr et", schema=schema, name="std", label="shared standard data") sharedTables = (Languages, Nations, PartnerTypes, Currencies, AuthorEventTypes, PublicationTypes, ProjectStati, Users) stddb.connect(conn,sharedTables) ## stddb.createTables() ## sess.use(stddb) ## from lino.schemas.sprl.data import std ## std.populate(sess,big=False) #sess.end() for dbi in dbinfos: if len(args) == 0 or dbi.name in args: info("Opening %s..." % dbi.name) db = Database( langs=dbi.langs, schema=schema, name=dbi.name, label=dbi.label) conn = Connection(filename=dbi.dbfile, schema=schema) db.update(stddb) db.connect(conn) ## sess.use(db) serverRsc.addDatabase(db, stylesheet="www.css") sess = center.startup(checkIntegrity=not options.skipTest) ## if not options.skipTest: ## db.checkIntegrity(sess) if True: sys.path.insert(0,demoDir) #for modName in ('vor', 'etc'): for modName in ('etc',): info("Opening %s..." % modName) mod = __import__(modName) # my_import(modName) #print "%s (%s)" % (modName,mod.label) conn = Connection(filename=modName+'.db', isTemporary=True, schema=schema) db = Database( langs='en de', schema=schema, name=modName, label=mod.label) db.startup(conn) db.createTables() sess.use(db) mod.populate(sess) serverRsc.addDatabase(db) ## , staticDirs = { ## 'files': os.path.join(demoDir,modName,'files'), ## 'images': os.path.join(demoDir,modName,'images'), ## #'thumbnails': os.path.join(demoDir,modName,'thumbnails') ## }) #db.flush() del sys.path[0] progress("Twisted Lino Server") progress(copyleft(year='2004',author='Luc Saffre')) from twisted.web import server from twisted.internet import reactor site = server.Site(serverRsc) site.requestFactory = MyRequest reactor.listenTCP(options.port, site) reactor.addSystemEventTrigger("before","shutdown", \ center.shutdown) progress("Serving on port %s." % options.port) progress("(Press Ctrl-C to stop serving)") reactor.run()
sys.exit(-1) if len(args) != 1: print __doc__ sys.exit(-1) for o, a in opts: if o in ("-?", "-h", "--help"): print __doc__ sys.exit() elif o in ("-o", "--output"): localBasepath = a elif o in ("-b", "--batch"): showOutput = False dbfile = args[0] ui = UI(verbose=True) schema = Schema() schema.startup(ui) conn = Connection(dbfile) #, isTemporary=True) db = ui.addDatabase(None, conn, schema, label="Lino Demo Database") db2html(db, localBasepath, baseuri) url = os.path.join(localBasepath, 'index.html') if showOutput: webbrowser.open(url, new=True)