예제 #1
0
	def store(self, logfunc=nopfunc):
		"Open and return my wikStore."
		if hasattr(self, '_my_store'):
			return self._my_store
			
		from wikklytext.store.wikStore_Q import wikStore_Q
		
		# note: do NOT cache results - this causes errors in wikStore_sqlite when
		# multiple threads try and access the same connection
		#from wikklytext.store import wikStore_files, wikStore_sqlite, wikStore_tw
	
		if not self.initted():
			raise Exception("** No wiki here - run 'wik init' first.")
			
		kind = self.get_kind()
		if kind == 'text':
			logfunc("OPENING STORE (%s,%s)" % (kind, self.get_path()))
			store = wikStore_Q('text', self.get_path())
		elif kind == 'tiddlywiki':
			logfunc("OPENING STORE (%s,%s)" % (kind, self.get_filename()))
			store = wikStore_Q('tiddlywiki', self.get_filename())
		elif kind == 'sqlite':
			logfunc("OPENING STORE (%s,%s)" % (kind, self.get_filename()))
			store = wikStore_Q('sqlite', self.get_filename())
		else:
			raise Exception("Bad kind")

		self._my_store = store
		return store
예제 #2
0
    def testMulti(self):
        "Multiple stores with one writer each."
        DB1 = 'testQA.db'
        DB2 = 'testQB.db'
        DB3 = 'testQC.db'
        if os.path.isfile(DB1): os.unlink(DB1)
        if os.path.isfile(DB2): os.unlink(DB2)
        if os.path.isfile(DB3): os.unlink(DB3)

        store1 = wikStore_Q('sqlite', DB1)
        store2 = wikStore_Q('sqlite', DB2)
        store3 = wikStore_Q('sqlite', DB3)
        threads = []
        threads.append(
            Thread(target=self.writer, args=(store1, ['aaa', 'bbb', 'ccc'])))
        threads.append(
            Thread(target=self.writer, args=(store2, ['ddd', 'eee', 'fff'])))
        threads.append(
            Thread(target=self.writer, args=(store3, ['ggg', 'hhh', 'iii'])))
        for t in threads:
            t.start()

        for t in threads:
            t.join()

        self.failUnless(set_(store1.names()) == set_(['aaa', 'bbb', 'ccc']))
        self.failUnless(set_(store2.names()) == set_(['ddd', 'eee', 'fff']))
        self.failUnless(set_(store3.names()) == set_(['ggg', 'hhh', 'iii']))
예제 #3
0
    def testWriting(self):
        "Multiple writers, single store."
        DBNAME = 'testQ.db'
        if os.path.isfile(DBNAME):
            os.unlink(DBNAME)

        store = wikStore_Q('sqlite', DBNAME)
        threads = []
        threads.append(
            Thread(target=self.writer, args=(store, ['aaa', 'bbb', 'ccc'])))
        threads.append(
            Thread(target=self.writer, args=(store, ['ddd', 'eee', 'fff'])))
        threads.append(
            Thread(target=self.writer, args=(store, ['ggg', 'hhh', 'iii'])))
        threads.append(
            Thread(target=self.writer, args=(store, ['jjj', 'kkk', 'lll'])))
        for t in threads:
            t.start()

        for t in threads:
            t.join()

        self.failUnless(
            set_(store.names()) == set_([
                'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii',
                'jjj', 'kkk', 'lll'
            ]))
예제 #4
0
    def testExc(self):
        "Ensure exceptions are passed up from worker thread"
        DBNAME = 'testQ.db'
        if os.path.isfile(DBNAME):
            os.unlink(DBNAME)

        store = wikStore_Q('sqlite', DBNAME)
        self.failUnlessRaises(StoreWorkerError, store.delete, 'aaa')
예제 #5
0
	def testRW_Q(self):
		from wikklytext.store.wikStore_Q import wikStore_Q, start, shutdown
		import os
		
		DBNAME = 'testsqliteQ.db'
		
		if os.path.isfile(DBNAME):
			os.unlink(DBNAME)
			
		store = wikStore_Q('sqlite', DBNAME)
		self.doStoreTests(store, u'WikklyText')		
예제 #6
0
    def testStoreQ(self):
        from wikklytext.store.wikStore_Q import wikStore_Q, start, shutdown
        import os

        DBNAME = 'testQ.db'

        if os.path.isfile(DBNAME):
            os.unlink(DBNAME)

        start()
        store = wikStore_Q('sqlite', DBNAME)
        self.doSearchWords(store)
        shutdown()
예제 #7
0
	def testStoreQ(self):
		from wikklytext.store.wikStore_Q import wikStore_Q, start, shutdown
		import os
		
		DBNAME = 'testQ.db'
		
		if os.path.isfile(DBNAME):
			os.unlink(DBNAME)
			
		start()
		store = wikStore_Q('sqlite', DBNAME)
		self.doSearchWords(store)	
		shutdown()