Merge lp:~openerp-dev/openobject-client/6.1-opw-573451-rgo into lp:openobject-client/6.1

Proposed by Ravi Gohil (OpenERP)
Status: Merged
Approved by: Naresh(OpenERP)
Approved revision: 2058
Merged at revision: 2068
Proposed branch: lp:~openerp-dev/openobject-client/6.1-opw-573451-rgo
Merge into: lp:openobject-client/6.1
Diff against target: 45 lines (+19/-3)
1 file modified
bin/modules/gui/main.py (+19/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client/6.1-opw-573451-rgo
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Review via email: mp+100772@code.launchpad.net

Description of the change

Hello,

GTK-Client allows user to set a New Database name with special characters while restoring a database.

This fix restricts naming database with special characters and allows only characters which are allowed by creation of database.

Kindly review it.

Thanks.

To post a comment you must log in.
2058. By Ravi Gohil (OpenERP)

[FIX] main.py: Restore database functionality allows user to set new Database Name with special characters: (Maintenance Case : 573451)

Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/modules/gui/main.py'
2--- bin/modules/gui/main.py 2011-12-09 11:22:31 +0000
3+++ bin/modules/gui/main.py 2012-04-05 06:57:17 +0000
4@@ -1387,6 +1387,11 @@
5 url, db_name, passwd = self._choose_db_ent()
6 if db_name:
7 try:
8+ id = rpc.session.db_exec(url, 'list', True)
9+ if db_name in id:
10+ common.warning(_("Could not create database."),
11+ _('Database already exists !'), parent=self.window)
12+ return
13 f = file(filename, 'rb')
14 data_b64 = base64.encodestring(f.read())
15 f.close()
16@@ -1578,15 +1583,26 @@
17 change_button.connect_after('clicked', lambda a,b: _server_ask(b, win),
18 widget_url)
19
20- res = win.run()
21-
22 db = False
23 passwd = False
24 url = False
25- if res == gtk.RESPONSE_OK:
26+
27+ while True:
28+ res = win.run()
29 db = db_widget.get_text()
30 url = widget_url.get_text()
31 passwd = widget_pass.get_text()
32+ if (res in (gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT)):
33+ self.window.present()
34+ win.destroy()
35+ return False, False, False
36+ if (res == gtk.RESPONSE_OK) and (db in RESERVED_KEYWORDS):
37+ common.warning(_("Sorry,'" + db + "' cannot be the name of the database,it's a Reserved Keyword."), _('Bad database name !'), parent=win)
38+ continue
39+ if (res == gtk.RESPONSE_OK) and ((not db) or (not re.match('^[a-zA-Z0-9][a-zA-Z0-9_]+$', db))):
40+ common.warning(_('The database name must contain only normal characters or "_".\nYou must avoid all accents, space or special characters.'), _('Bad database name !'), parent=win)
41+ else:
42+ break
43 self.window.present()
44 win.destroy()
45 return url, db, passwd

Subscribers

People subscribed via source and target branches