It is currently Sun Feb 12, 2012 6:37 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to dblist.filter in GTK-client?
PostPosted: Wed Feb 24, 2010 8:06 pm 
Offline

Joined: Fri Feb 12, 2010 10:57 am
Posts: 31
Are there any possibility to filter databases that are sent to the client in a similar way that is done in the web-client?

The web-client can ask for / filter databases using the subdomain eg db1.example.com will return db1_demo and db1 in the database drop-down (if there are those databases on the server) using the dblist.filter directive in /etc/openerp-web.conf.

It would be nice if it was possible to filter databases on server side like its done in base.py in the webclient.


rpc.py (webclient)
def listdb(self):
try:
return self.execute_noauth('db', 'list')
except Exception, e:
return -1

base.py (webclient)
headers = cherrypy.request.headers
host = headers.get('X-Forwarded-Host', headers.get('Host'))
...
if dbfilter == 'BOTH':
dblist = [d for d in dblist if d.startswith(base + '_') or d == base]


rpc.py (openerp-client)
def list_db(self, url):
try:
return self.db_exec_no_except(url, 'list')
except Exception, e:
return -1

webservice.py (db/list in openerp-server)
def list(self):
db = sql_db.db_connect('template1')
cr = db.cursor()
try:
try:
db_user = tools.config["db_user"]
if not db_user and os.name == 'posix':
import pwd
db_user = pwd.getpwuid(os.getuid())[0]
if not db_user:
cr.execute("select decode(usename, 'escape') from pg_user where usesysid=(select datdba from pg_database where datname=%s)", (tools.config["db_name"],))
res = cr.fetchone()
db_user = res and str(res[0])
if db_user:
cr.execute("select decode(datname, 'escape') from pg_database where datdba=(select usesysid from pg_user where usename=%s) and datname not in ('template0', 'template1', 'postgres') order by datname", (db_user,))
else:
cr.execute("select decode(datname, 'escape') from pg_database where datname not in('template0', 'template1','postgres') order by datname")
res = [str(name) for (name,) in cr.fetchall()]
except:
res = []
finally:
cr.close()
sql_db.close_db('template1')
res.sort()
return res


Top
 Profile  
 
 Post subject: Re: How to dblist.filter in GTK-client?
PostPosted: Mon Dec 06, 2010 8:04 pm 
Offline

Joined: Tue Sep 14, 2010 9:06 pm
Posts: 13
Location: France
Hi Anders_W

Unfortunatly, I don't the answer to your question but I need to test the filter functionality by filtered the databases using subdomains within the web client.
Can you teach me (quickly) how to do that please?

Thanks in advance and regards

Bodays


Top
 Profile  
 
 Post subject: Re: How to dblist.filter in GTK-client?
PostPosted: Fri Dec 10, 2010 2:17 pm 
Offline

Joined: Fri Feb 12, 2010 10:57 am
Posts: 31
In the file /etc/openerp-web.cfg:

# Web client settings
[openerp-web]
# filter dblists based on url pattern?
# NONE: No Filter
# EXACT: Exact Hostname
# UNDERSCORE: Hostname_
# BOTH: Exact Hostname or Hostname_

dblist.filter = 'BOTH'

# whether to show Databases button on Login screen or not
dbbutton.visible = False



This means that your subdomain db1 will be used for the url http://db1.example.com
You have to point all your subdomains (you want as database) to your openerp-web-server via your dns.


Top
 Profile  
 
 Post subject: Re: How to dblist.filter in GTK-client?
PostPosted: Tue Dec 14, 2010 10:52 pm 
Offline

Joined: Tue Sep 14, 2010 9:06 pm
Posts: 13
Location: France
Thanks Anders_W!

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP