Re: Working example for calling a specific form from a python script

Jan Ischebeck <[email protected]> Fri, 17 Nov 2006 15:42:57 +0100
Newsgroups gmane.comp.gnu.enterprise.general
Message-ID <[email protected]>
Hi Adrian,

to remove the annoying  text mode  user/password questions you can use 
the SilentLoginHandler.

Add to imports:
from gnue.common.datasources.GLoginHandler import SilentLoginHandler

Add to constructor:
loginHandler = SilentLoginHandler (_username = user, _password = paswd)
self.connections.setLoginHandler (loginHandler)

An example can be found in GeasRpcServer.py (in appserver/src)

Regards, Jan

Adrian Maier schrieb:
> On 11/17/06, Jan Ischebeck <[email protected]> wrote:
>> Hi Adrian,
>>
>> the following example is working for me (latest development version).
>>
>> Jan
>>
>> #!/usr/bin/python
>>
>> from gnue.forms.GFInstance import GFInstance
>> from gnue.forms.uidrivers import wx26 as ui
>> from gnue.forms.GFConfig import ConfigOptions
>> from gnue.common.apps.GClientApp import GClientApp
>>
>> class gfdrunner(GClientApp):
>>   def __init__ (self, connections = None):
>>     self.OPTIONS['username'] = "myname"
>>     self.OPTIONS['password'] = "mypassword"
>>     GClientApp.__init__ (self, connections, 'forms', ConfigOptions)
>>
>>     self.configurationManager.registerAlias ('gConfigForms', 'forms')
>>
>>   def run(self):
>>     instance = GFInstance(manager=self,
>>                connections=self.connections,
>>                ui=ui, disableSplash=1)
>>
>>     instance.addFormFromFile('F:\gnue\samples\gauntlet.gfd')
>>     instance.activate()
>>
>> r = gfdrunner()
>> r.run()
>
> Hello Jan,
>
> This script works here, too. But it asked me for a username and password,
> in console mode :
>
> ************************************************************
> GNU Enterprise: Login to db_faf
>
>  Login required for
> "DB_FAF"
>
>  User Name: am
>  Password:
>
> Then the form started with the wx ui.  A little strange, but it's an 
> important
> step forward:  the form ran !
>
> James had explained me a couple of days ago, on irc,  that it's 
> necessary to
> define a login manager class that returns the user and password.  I'll 
> try doing
> that next.
>
>
> Thanks !
>
> Adrian Maier
>
>
> _______________________________________________
> Gnue mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/gnue