def app_db(modules=None): a = ApplicationBase() a.Register(appconf) if modules: for m in modules: a.Register(m) p = Portal() p.Register(a, "nive") a.SetupApplication() dbfile = DvPath(a.dbConfiguration.dbName) if not dbfile.IsFile(): dbfile.CreateDirectories() root = DvPath(a.dbConfiguration.fileRoot) if not root.IsDirectory(): root.CreateDirectories() try: a.Query("select id from pool_meta where id=1") a.Query("select id from data1 where id=1") a.Query("select id from data2 where id=1") a.Query("select id from data3 where id=1") a.Query("select id from pool_files where id=1") a.Query("select id from pool_sys where id=1") a.Query("select id from pool_groups where id=1") a.Query("select title from pool_meta where id=1") except: a.GetTool("nive.tools.dbStructureUpdater")() # disable this to update test tables each time the tests are called #a.GetTool("nive.tools.dbStructureUpdater")() a.Startup(None) # this will reset all testdata #emptypool(a) return a
def myapp(modules=None): a = ApplicationBase() a.Register(appconf) a.Register(dbconfMySql) if modules: for m in modules: a.Register(m) p = Portal() p.Register(a, "nive") a.LoadConfiguration() root = DvPath(a.dbConfiguration.fileRoot) if not root.IsDirectory(): root.CreateDirectories() try: a.Query("select id from pool_meta where id=1") a.Query("select id from data1 where id=1") a.Query("select id from data2 where id=1") a.Query("select id from data3 where id=1") a.Query("select id from pool_files where id=1") a.Query("select id from pool_sys where id=1") a.Query("select id from pool_groups where id=1") except: a.GetTool("nive.components.tools.dbStructureUpdater")() a.Startup(None) return a
def commitTemp(self, fileentry): """ This functions writes the file to the pool directory. If the file is not marked as tempfile, nothing is written. Files are processed in the following order: - a temp path is created - the file is written to this path - the original file is renamed to be deleted on success and stored as `file.deleteOnSuccess` - the tempfile is renamed to the original path - the original file can be removed by calling `Cleanup()` fileentry is the database entry the file is stored for. """ if not self.isTempFile(): # nothing to write -> return return True if not self.fileentry: self.fileentry = weakref.ref(fileentry) maxFileSize = fileentry.maxFileSize if self.size and self.size > maxFileSize: raise IOError, "File too big" # create temp path for current backupPath = None originalPath = DvPath(self._Path()) newPath = DvPath(self._CreatePath(self.filekey, self.filename)) tempPath = DvPath(str(newPath)) tempPath.SetName(u"_temp_" + unicode(uuid.uuid4())) tempPath.SetExtension(newPath.GetExtension()) if tempPath.Exists(): tempPath.Delete() tempPath.CreateDirectories() size = 0 try: out = open(tempPath.GetStr(), "wb") data = self.read(10000) while data: size += len(data) if maxFileSize and size > maxFileSize: raise IOError, "File too big" out.write(data) data = self.read(10000) out.close() #file.close() except Exception, e: try: self.file.close() except: pass try: out.close() except: pass # reset old file tempPath.Delete() raise Exception, e
def setUp(self): self.pool = getPool() dbfile = DvPath(conn["dbName"]) if not dbfile.IsFile(): dbfile.CreateDirectories() self.checkdb() self.connect()
def setUp(self): dbfile = DvPath(conn["dbName"]) if not dbfile.IsFile(): dbfile.CreateDirectories() checkdb() db = Sqlite3(conf, conn) db.GetPoolStructureObj().SetStructure(struct) self.pool = db
def setUp(self): conn = DatabaseConf(DB_CONF) p = Sqlite3(connParam=conn, **test_Base.conf) p.structure.Init(structure=test_Base.struct, stdMeta=test_Base.struct[u"pool_meta"]) dbfile = DvPath(conn["dbName"]) if not dbfile.IsFile(): dbfile.CreateDirectories() self.pool = p self.pool.connection.connect()
def test_fncs(self): temp = tempfile.gettempdir() p = DvPath(temp) p.AppendDirectory("tmp_nivepathtest_000") p.Delete(deleteSubdirs=True) p.CreateDirectories() self.assert_(p.IsDirectory()) p.CreateDirectoriesExcp() p.Rename("tmp_nivepathtest_111") p.AppendDirectory("tmp_nivepathtest_000") p.AppendDirectory("tmp_nivepathtest_000") p.CreateDirectories() self.assert_(p.IsDirectory()) p = DvPath(temp) p.AppendDirectory("tmp_nivepathtest_000") p.Delete(deleteSubdirs=False) self.assert_(p.IsDirectory() == True) p.Delete(deleteSubdirs=True) self.assert_(p.IsDirectory() == False)
def app(confs=[]): a = WebsitePublisher() a.Register(appconf) a.Register(dbconf) for c in confs: a.Register(c) p = Portal() p.Register(a) a.Startup(None) dbfile = DvPath(a.dbConfiguration.dbName) if not dbfile.IsFile(): dbfile.CreateDirectories() try: a.Query("select id from pool_meta where id=1") a.Query("select id from data1 where id=1") a.Query("select id from data2 where id=1") a.Query("select id from data3 where id=1") a.Query("select id from pool_files where id=1") except: a.GetTool("nive.components.tools.dbStructureUpdater")() return a
def __test(): dbfile = DvPath(conn["dbName"]) if not dbfile.IsFile(): dbfile.CreateDirectories() checkdb() db = Sqlite3(conf, conn) db.GetPoolStructureObj().SetStructure(struct) app = Sqlite3ConnMultithreading() app.pool = db app.setUp() threadcnt = 10 ts = [] for i in range(threadcnt): t = ThreadClass() ts.append(t) t.app = app t.start() for t in ts: t.join() print "OK"
def app_db(confs=None): a = DataStorage() a.Register(appconf) if confs: for c in confs: a.Register(c) p = Portal() p.Register(a) a.Startup(None) dbfile = DvPath(a.dbConfiguration.dbName) if not dbfile.IsFile(): dbfile.CreateDirectories() try: a.Query("select id from pool_meta where id=1") a.Query("select pool_wfp from pool_meta where id=1") a.Query("select id from bookmarks where id=1") a.Query("select id from tracks where id=1") a.Query("select id from pool_files where id=1") except: a.GetTool("nive.tools.dbStructureUpdater")() return a
def app(extmodules=None): appconf = AppConf("nive.userdb.app") appconf.modules.append("nive.userdb.userview.view") appconf.modules.append("nive.components.tools.sendMail") a = UserDB(appconf) a.dbConfiguration = dbconf p = Portal() p.Register(a) a.Startup(None) dbfile = DvPath(a.dbConfiguration.dbName) if not dbfile.IsFile(): dbfile.CreateDirectories() try: a.Query("select id from pool_meta where id=1") a.Query("select id from data1 where id=1") a.Query("select id from data2 where id=1") a.Query("select id from data3 where id=1") a.Query("select id from pool_files where id=1") except: a.GetTool("nive.components.tools.dbStructureUpdater")() return a
def app_db(confs=None): appconf = AppConf("nive_cms.app") a = WebsitePublisher() a.Register(appconf) if confs: for c in confs: a.Register(c) p = Portal() p.Register(a) a.Startup(None) dbfile = DvPath(a.dbConfiguration.dbName) if not dbfile.IsFile(): dbfile.CreateDirectories() try: a.Query("select id from pool_meta where id=1") a.Query("select id from box where id=1") a.Query("select id from columnbox where id=1") a.Query("select id from texts where id=1") a.Query("select id from pool_files where id=1") except: a.GetTool("nive.tools.dbStructureUpdater")() return a
def app_db(confs=None): appconf = AppConf("nive_userdb.app") appconf.modules.append("nive_userdb.userview.view") appconf.modules.append("nive.tools.sendMailTester") a = UserDB() a.Register(appconf) if confs: for c in confs: a.Register(c) p = Portal() p.Register(a) a.Startup(None) dbfile = DvPath(a.dbConfiguration.dbName) if not dbfile.IsFile(): dbfile.CreateDirectories() try: a.Query("select id from pool_meta where id=1") a.Query("select id from users where id=1") a.Query("select id from users where token='1'") a.Query("select id from users where tempcache='1'") a.Query("select id from pool_files where id=1") except: a.GetTool("nive.tools.dbStructureUpdater")() return a