Exemplo n.º 1
0
    def __init__(self, aServerList=[]):
        QtCore.QObject.__init__(self)
        self.app = QtGui.QApplication([])
        self.myMainWindow = self.mainWindow()

        self.prefs = {}
        self.dbeFactory = dbschema.dbeFactory

        for s in aServerList:
            try:
                # Connection
                myconn = createConnection(s['url'], False)  #True)
                # Server
                server = dbschema.ObjectMgr(myconn, False, 'rra')
                server.setDBEFactory(self.dbeFactory)
                server.connect()
                server.login(s['user'], s['pwd'])
                # Form Factory
                formFactory = FormFactory()
                for f in formschema.formschema_type_list.keys():
                    formFactory.register(f, formschema.formschema_type_list[f],
                                         server)
                # Widget
                widget = serverwidget.ServerWidget(self.myMainWindow,
                                                   "TestWidget")
                widget.setServer(server)
                widget.setFormFactory(formFactory)
                widget.setContainer(self)
                # Slots
                QtCore.QObject.connect(widget, QtCore.SIGNAL("updatedTree()"),
                                       self.slotUpdatedTree)
                QtCore.QObject.connect(
                    widget,
                    QtCore.SIGNAL("selected(QStandardItem,PyQt_PyObject)"),
                    self.slotSelected)
                QtCore.QObject.connect(widget, QtCore.SIGNAL("updatedTree()"),
                                       self.slotUpdatedTree)
                # Initial Search
                widget.runSearchFolder(
                    "", "DBEFolder")  #("test",'DBEProject') #'DBEFolder')
                # Add
                self.centralwidget.addTab(
                    widget,
                    "%s::%s" % (server.getConnectionProvider().getDBType(),
                                widget.getName()))
            except Exception, e:
                print "ECCEZIONE:", e
                print "".join(traceback.format_tb(sys.exc_info()[2]))
Exemplo n.º 2
0
	def __init__(self,aFormList=[],aServerDefinition={}):
		QtCore.QObject.__init__(self)
		self.app = QtGui.QApplication([])
		self.myMainWindow = self.mainWindow()
		
		self.prefs={}
		
		self.dbeFactory = dbschema.dbeFactory
		
		if len(aServerDefinition)>0:
			#print aServerDefinition
			s = aServerDefinition
			# Connection
			myconn = createConnection(s['url'],False)
			# Server
			server = dbschema.ObjectMgr(myconn, False, s['schema'])
			server.setDBEFactory(self.dbeFactory)
			server.connect()
			server.login(s['user'],s['pwd'])
		# Form Factory
		self.formFactory = FormFactory()
		for f in formschema.formschema_type_list.keys():
			self.formFactory.register(f,formschema.formschema_type_list[f],server)
		formList = self.formFactory.getAllClassnames()
		formList.sort()
		if len(aFormList)>0:
			formList = aFormList
		for _f in formList:
			print "TestWidget.__init__: _f=%s" % ( _f )
			if _f in ['default','FProjectCompany','FProjectPeople','FProjectProject','FUserGroupAssociation',]:
				continue
			myform = self.formFactory.getInstance(_f,'','',"POST",server)
			try:
				widget = searchwidget.SearchWidget(self.myMainWindow,"testFilter_%s"%_f,myform,True) #,False)
				widget.setServer(server)
				widget.setFormFactory(self.formFactory)
				widget.container=self
				QtCore.QObject.connect(widget,QtCore.SIGNAL("updatedList()"),self.slotUpdatedList)
				QtCore.QObject.connect(widget,QtCore.SIGNAL("selected(QListWidgetItem,PyQt_PyObject)"),self.slotSelected)
				self.centralwidget.addTab(widget,myform.getDetailTitle())
				#self.addForm(myform)
			except Exception,e:
				print "ECCEZIONE:",e
				print "".join(traceback.format_tb(sys.exc_info()[2]))
Exemplo n.º 3
0
def main():
    TEST_CONNECTOR = "sqlitedb"
    if len(sys.argv) > 1:
        TEST_CONNECTOR = sys.argv[1]
    local_filename = 'test_dbconnector.py'
    local_filename2 = 'test_explorer.py'
    email_filename = "test.eml"
    if len(sys.argv) > 2:
        local_filename = sys.argv[2]
    if len(sys.argv) > 3:
        local_filename2 = sys.argv[3]
    if len(sys.argv) > 4:
        email_filename = sys.argv[4]

    dbschema.dbeFactory.verbose = False
    myconn = None
    if TEST_CONNECTOR == 'mydb':
        from rprj.dblayer.mydb import MYConnectionProvider
        myconn = MYConnectionProvider('localhost', 'rproject', 'root', '',
                                      True)
    elif TEST_CONNECTOR == 'pgdb':
        from rprj.dblayer.pgdb import PGConnectionProvider
        myconn = PGConnectionProvider('127.0.0.1', 'rproject', 'roberto', '',
                                      True)
    elif TEST_CONNECTOR == 'sqlitedb':
        from rprj.dblayer.sqlitedb import SQLiteConnectionProvider
        RPRJ_LOCAL_DB = "%s%s.config%srprj%srprj.db" % (
            os.path.expanduser("~"), os.path.sep, os.path.sep, os.path.sep)
        myconn = SQLiteConnectionProvider('', './test.db', '', '', True)
        #myconn = SQLiteConnectionProvider( '', '/home/roberto/.config/rprj/rprj.db','','', True )
    elif TEST_CONNECTOR == 'winodbc':
        from rprj.dblayer.winodbc import WinOdbcConnectionProvider
        myconn = WinOdbcConnectionProvider('localhost', 'rproject', 'adm',
                                           'adm', True)
    elif TEST_CONNECTOR == 'xmlrpc':
        from rprj.dblayer.xmlrpc import XmlrpcConnectionProvider
        if sys.platform == 'darwin':
            myconn = XmlrpcConnectionProvider(
                'http://localhost/~robertoroccoangeloni/rproject/xmlrpc_server.php',
                '', '', '', False)
        else:
            myconn = XmlrpcConnectionProvider(
                'http://localhost/~roberto/rproject/xmlrpc_server.php', '', '',
                '', False)
    elif TEST_CONNECTOR == 'json':
        from rprj.dblayer.jsonconn import JsonConnectionProvider
        if sys.platform == 'darwin':
            myconn = JsonConnectionProvider(
                'json://localhost/~robertoroccoangeloni/rproject/jsonserver.php',
                '', '', '', True)
        else:
            myconn = JsonConnectionProvider(
                'json://localhost/~roberto/rproject/jsonserver.php', '', '',
                '', False)

    dbmgr = dbschema.ObjectMgr(myconn, False, 'test')
    dbmgr.setDBEFactory(dbschema.dbeFactory)

    print "======================= Connect ======================="
    dbmgr.connect()
    print "ping:", dbmgr.ping()
    dbmgr.removeDB()

    print "======================= isLoggedIn ======================="
    print "isLoggedIn:", dbmgr.isLoggedIn()

    print "======================= Login & InitDB ======================="
    dbmgr._verbose = True
    dbmgr.login('roberto', 'cippalippa')
    dbmgr._verbose = False

    print "isLoggedIn:", dbmgr.isLoggedIn()
    print "User:"******"Groups:", dbmgr.getUserGroupsList()
    if not dbmgr.isLoggedIn():
        print "Exiting: not logged in"
        exit(1)
    try:
        print "======================= Insert ======================="
        nuova = dbmgr.getClazzByTypeName('DBEFolder')(attrs={
            'name': u"prova folder à"
        })
        dbefolder = dbmgr.insert(nuova)
        print "dbefolder:", dbefolder
        nuova = dbmgr.getClazzByTypeName('DBENote')(attrs={
            'name': "prova nota"
        })
        nuova.readFKFrom(dbefolder)
        dbe = dbmgr.insert(nuova)
        print "dbe:", dbe

        print "======================= ObjectMgr ======================="
        #myconn.verbose=True
        print "      ObjectById:", dbmgr.objectById(dbefolder.getValue('id'))
        print "  fullObjectById:", dbmgr.fullObjectById(
            dbefolder.getValue('id'))
        print "    ObjectByName:", dbefolder.getValue(
            'name'), "->", dbmgr.objectByName(dbefolder.getValue('name'))
        print "fullObjectByName:", dbefolder.getValue(
            'name'), "->", dbmgr.fullObjectByName(dbefolder.getValue('name'))
        myconn.verbose = False

        print "======================= Upload ======================="
        dbefile = None
        dbmgr._verbose = True
        try:
            filename = dbmgr.uploadFile(local_filename)
            dbefile = dbmgr.getClazzByTypeName('DBEFile')(attrs={
                'filename': filename
            })
            dbefile = dbmgr.insert(dbefile)
            #print myconn.lastMessages
            print "dbefile:", dbefile
        except Exception, e:
            print "--> Upload NOT available: %s" % e
            print "".join(traceback.format_tb(sys.exc_info()[2]))
            raise e
        dbmgr._verbose = False

        dbemail = None
        try:
            dbemail = dbmgr.getClazzByTypeName('DBEMail')(
                attrs={
                    'filename': email_filename
                })
            #dbmgr._verbose=True
            dbemail = dbmgr.insert(dbemail)
            dbmgr._verbose = False
            #print myconn.lastMessages
            print "dbemail:", dbemail.getValue('id'), dbemail.getValue('name')
            print "\t", dbemail.getValue('msgdate'), dbemail.getValue(
                'subject')
        except Exception, e:
            print "--> Upload NOT available: %s" % e
            print "".join(traceback.format_tb(sys.exc_info()[2]))
            raise e
Exemplo n.º 4
0
    def setUp(self):
        self.TEST_CONNECTOR = "json_wsgi"  #mongodb sqlitedb xmlrpc
        if len(sys.argv) > 1:
            self.TEST_CONNECTOR = sys.argv[1]
        self.local_filename = 'test_dbconnector.py'
        self.local_filename2 = 'test_explorer.py'
        self.email_filename = "test.eml"
        if len(sys.argv) > 2:
            self.local_filename = sys.argv[2]
        if len(sys.argv) > 3:
            self.local_filename2 = sys.argv[3]
        if len(sys.argv) > 4:
            self.email_filename = sys.argv[4]

        dbschema.dbeFactory.verbose = False
        self.myconn = None
        if self.TEST_CONNECTOR == 'mydb':
            from rprj.dblayer.mydb import MYConnectionProvider
            self.myconn = MYConnectionProvider('localhost', 'rproject', 'root',
                                               '', True)
        elif self.TEST_CONNECTOR == 'pgdb':
            from rprj.dblayer.pgdb import PGConnectionProvider
            self.myconn = PGConnectionProvider('127.0.0.1', 'rproject',
                                               'roberto', '', True)
        elif self.TEST_CONNECTOR == 'sqlitedb':
            from rprj.dblayer.sqlitedb import SQLiteConnectionProvider
            self.RPRJ_LOCAL_DB = "%s%s.config%srprj%srprj.db" % (
                os.path.expanduser("~"), os.path.sep, os.path.sep, os.path.sep)
            self.myconn = SQLiteConnectionProvider('', './test.db', '', '',
                                                   True)
            #myconn = SQLiteConnectionProvider( '', '/home/roberto/.config/rprj/rprj.db','','', True )
        elif self.TEST_CONNECTOR == 'winodbc':
            from rprj.dblayer.winodbc import WinOdbcConnectionProvider
            self.myconn = WinOdbcConnectionProvider('localhost', 'rproject',
                                                    'adm', 'adm', True)
        elif self.TEST_CONNECTOR == 'xmlrpc':
            from rprj.dblayer.xmlrpc import XmlrpcConnectionProvider
            if sys.platform == 'darwin':
                self.myconn = XmlrpcConnectionProvider(
                    'http://localhost/~robertoroccoangeloni/rproject/xmlrpc_server.php',
                    '', '', '', False)
            else:
                self.myconn = XmlrpcConnectionProvider(
                    'http://localhost/~roberto/rproject/xmlrpc_server.php', '',
                    '', '', False)
        elif self.TEST_CONNECTOR == 'json':
            from rprj.dblayer.jsonconn import JsonConnectionProvider
            if sys.platform == 'darwin':
                self.myconn = JsonConnectionProvider(
                    'json://localhost/~robertoroccoangeloni/rproject/jsonserver.php',
                    '', '', '', True)
            else:
                self.myconn = JsonConnectionProvider(
                    'json://localhost/~roberto/rproject/jsonserver.php', '',
                    '', '', False)
        elif self.TEST_CONNECTOR == 'json_wsgi':
            from rprj.dblayer.jsonconn import JsonConnectionProvider
            self.myconn = JsonConnectionProvider('json://localhost:1771', '',
                                                 '', '', True)
        elif self.TEST_CONNECTOR == 'mongodb':
            from rprj.dblayer.mongo import MongoConnectionProvider
            self.myconn = MongoConnectionProvider('localhost', 'rproject',
                                                  'adm', 'adm', True)
        self.dbmgr = dbschema.ObjectMgr(self.myconn, False, 'test')
        self.dbmgr.setDBEFactory(dbschema.dbeFactory)

        self.dbmgr.connect()