From 7627a051da62e2113ef2ef19e6f368986eb99833 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 5 Aug 2011 17:43:53 +0530 Subject: [PATCH 01/11] restore db fix. Allow dbname with $. Terminal didn't allow $ without escape char. --- cgi-bin/webnotes/model/db_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/model/db_schema.py b/cgi-bin/webnotes/model/db_schema.py index 0ab2de0b78..e1e02058d2 100644 --- a/cgi-bin/webnotes/model/db_schema.py +++ b/cgi-bin/webnotes/model/db_schema.py @@ -358,7 +358,7 @@ class DbManager: mysql = mysql_path and os.path.join(mysql_path, 'mysql') or 'mysql' try: - ret = os.system("%s -u root -p%s %s < %s"%(mysql, root_password.replace(" ", "\ "), target, source)) + ret = os.system("%s -u root -p%s %s < %s"%(mysql, root_password.replace(" ", "\ "), target.replace("$", "\$"), source)) except Exception,e: raise e From 1db133f81c1900ea795c8677a2ff9ddf1e877289 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 8 Aug 2011 12:55:23 +0530 Subject: [PATCH 02/11] delete all childs from localdb while deleting parent --- js/form.compressed.js | 2 +- js/widgets/form/form.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/form.compressed.js b/js/form.compressed.js index 32c2369634..0965a48d2b 100644 --- a/js/form.compressed.js +++ b/js/form.compressed.js @@ -181,7 +181,7 @@ _f.Frm.prototype.savedoc=function(save_action,onsave,onerr){this.error_in_sectio _f.Frm.prototype.saveupdate=function(){this.save('Update');} _f.Frm.prototype.savesubmit=function(){var answer=confirm("Permanently Submit "+this.docname+"?");if(answer)this.save('Submit');} _f.Frm.prototype.savecancel=function(){var answer=confirm("Permanently Cancel "+this.docname+"?");if(answer)this.save('Cancel');} -_f.Frm.prototype.savetrash=function(){var me=this;var answer=confirm("Permanently Delete "+this.docname+"? This action cannot be reversed");if(answer){$c('webnotes.model.delete_doc',{dt:this.doctype,dn:this.docname},function(r,rt){if(r.message=='okay'){delete locals[me.doctype][me.docname];if(page_body.wntoolbar)page_body.wntoolbar.rdocs.remove(me.doctype,me.docname);nav_obj.show_last_open();}})}} +_f.Frm.prototype.savetrash=function(){var me=this;var answer=confirm("Permanently Delete "+this.docname+"? This action cannot be reversed");if(answer){$c('webnotes.model.delete_doc',{dt:this.doctype,dn:this.docname},function(r,rt){if(r.message=='okay'){LocalDB.delete_doc(me.doctype,me.docname);if(page_body.wntoolbar)page_body.wntoolbar.rdocs.remove(me.doctype,me.docname);nav_obj.show_last_open();}})}} _f.Frm.prototype.amend_doc=function(){if(!this.fields_dict['amended_from']){alert('"amended_from" field must be present to do an amendment.');return;} var me=this;var fn=function(newdoc){newdoc.amended_from=me.docname;if(me.fields_dict&&me.fields_dict['amendment_date']) newdoc.amendment_date=dateutil.obj_to_str(new Date());} diff --git a/js/widgets/form/form.js b/js/widgets/form/form.js index 207f45f841..0202f92e03 100644 --- a/js/widgets/form/form.js +++ b/js/widgets/form/form.js @@ -1118,7 +1118,7 @@ _f.Frm.prototype.savetrash = function() { $c('webnotes.model.delete_doc', {dt:this.doctype, dn:this.docname}, function(r,rt) { if(r.message=='okay') { // delete from locals - delete locals[me.doctype][me.docname]; + LocalDB.delete_doc(me.doctype, me.docname); // delete from recent if(page_body.wntoolbar) page_body.wntoolbar.rdocs.remove(me.doctype, me.docname); From d99d252a702e10618732e31f5a311529e466ec39 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 8 Aug 2011 16:28:10 +0530 Subject: [PATCH 03/11] Block unregistered users from resetting password --- cgi-bin/webnotes/profile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index dd135ee1ba..57d938f2a4 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -149,11 +149,14 @@ class Profile: pwd = self.get_random_password() # get profile - profile = webnotes.conn.sql("SELECT name, email, first_name, last_name FROM tabProfile WHERE name=%s OR email=%s",(self.name, self.name)) + profile = webnotes.conn.sql("SELECT name, email, first_name, last_name, registered FROM tabProfile WHERE name=%s OR email=%s",(self.name, self.name)) if not profile: raise Exception, "Profile %s not found" % self.name - + elif not profile[0][4]: + # if an unregistered user tries to reset password + raise Exception, "You cannot reset your password as you have not completed registration. You need to complete registration using the link provided in the email." + # update tab Profile webnotes.conn.sql("UPDATE tabProfile SET password=password(%s) WHERE name=%s", (pwd, profile[0][0])) From ce61112bfd44f5ce74d446b4ae9a8b19349b1488 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 8 Aug 2011 16:52:09 +0530 Subject: [PATCH 04/11] Block a user from resetting password if registration is not complete --- cgi-bin/webnotes/profile.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index 57d938f2a4..bb9a201da2 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -149,13 +149,16 @@ class Profile: pwd = self.get_random_password() # get profile - profile = webnotes.conn.sql("SELECT name, email, first_name, last_name, registered FROM tabProfile WHERE name=%s OR email=%s",(self.name, self.name)) - + profile = webnotes.conn.sql("SELECT name, email, first_name, last_name FROM tabProfile WHERE name=%s OR email=%s",(self.name, self.name)) + + profile_cols = [desc[0] for desc in webnotes.conn.sql("DESCRIBE tabProfile")] + if not profile: raise Exception, "Profile %s not found" % self.name - elif not profile[0][4]: + elif 'registered' in profile_cols: + if not webnotes.conn.sql("SELECT registered FROM tabProfile WHERE name=%s", self.name)[0][0]: # if an unregistered user tries to reset password - raise Exception, "You cannot reset your password as you have not completed registration. You need to complete registration using the link provided in the email." + raise Exception, "You cannot reset your password as you have not completed registration. You need to complete registration using the link provided in the email." # update tab Profile webnotes.conn.sql("UPDATE tabProfile SET password=password(%s) WHERE name=%s", (pwd, profile[0][0])) From 0698438c746ef664a2c4a883b0c276420626728f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 11 Aug 2011 17:41:45 +0530 Subject: [PATCH 05/11] utf issue in recent --- cgi-bin/webnotes/profile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index bb9a201da2..3fe1eec59d 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -176,12 +176,14 @@ class Profile: Update the user's `Recent` list with the given `dt` and `dn` """ conn = webnotes.conn + from webnotes.utils import cstr # get list of child tables, so we know what not to add in the recent list child_tables = [t[0] for t in conn.sql('select name from tabDocType where istable = 1')] + if not (dt in ['Print Format', 'Start Page', 'Event', 'ToDo Item', 'Search Criteria']) and not webnotes.is_testing and not (dt in child_tables): - r = webnotes.conn.sql("select recent_documents from tabProfile where name=%s", self.name)[0][0] or '' - new_str = dt+'~~~'+dn + '\n' + r = cstr(webnotes.conn.sql("select recent_documents from tabProfile where name=%s", self.name)[0][0] or '') + new_str = cstr(dt)+'~~~'+cstr(dn) + '\n' if new_str in r: r = r.replace(new_str, '') From a9f947f305fa4c0a59aa64be028cccc7f070bc8b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 12 Aug 2011 10:56:44 +0530 Subject: [PATCH 06/11] fixed issue for utf-8 --- cgi-bin/webnotes/db.py | 26 +++++++++++++++++++++++--- cgi-bin/webnotes/handler.py | 9 +++------ cgi-bin/webnotes/utils/__init__.py | 16 +++++----------- js/form.compressed.js | 2 +- js/utils/handler.js | 2 +- js/widgets/form/clientscriptAPI.js | 3 +-- js/wnf.compressed.js | 2 +- 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/cgi-bin/webnotes/db.py b/cgi-bin/webnotes/db.py index aae4d5b02d..8d175e317e 100644 --- a/cgi-bin/webnotes/db.py +++ b/cgi-bin/webnotes/db.py @@ -15,9 +15,6 @@ class Database: self.host = host or 'localhost' self.user = user or getattr(defs, 'default_db_name', '') - # password can be empty string - self.password = password==None and getattr(defs, 'db_password', '') or password - if ac_name: self.user = self.get_db_login(ac_name) or defs.default_db_name @@ -28,6 +25,8 @@ class Database: self.in_transaction = 0 self.transaction_writes = 0 self.testing_tables = [] + + self.password = self.get_db_password(ac_name, password) self.connect() if self.user != 'root': @@ -36,6 +35,27 @@ class Database: if webnotes.logger: webnotes.logger.debug('Database object initialized for:%s',self.user) + def get_db_password(self, db_name, password): + """ + Return db password. order of importance: + + 1. password + 2. defs.get_db_password() + 3. defs.db_password + """ + # password can be empty string + if password: + return password + + if hasattr(defs, 'get_db_password'): + return defs.get_db_password(db_name) + + if hasattr(defs, 'db_password'): + return defs.db_password + + else: + return '' + def get_db_login(self, ac_name): return getattr(defs,'db_name_map').get(ac_name, getattr(defs,'default_db_name')) diff --git a/cgi-bin/webnotes/handler.py b/cgi-bin/webnotes/handler.py index 760a96e8e4..f432c91ff8 100755 --- a/cgi-bin/webnotes/handler.py +++ b/cgi-bin/webnotes/handler.py @@ -410,17 +410,14 @@ else: except: # python 2.4 import simplejson as json - try: - str_out = json.dumps(webnotes.response) - except: - str_out = str(webnotes.response).replace(', None', ', ""') + str_out = json.dumps(webnotes.response) - if acceptsGzip and len(str_out)>512: + if acceptsGzip and 1 and len(str_out)>512: out_buf = compressBuf(str_out) print "Content-Encoding: gzip" print "Content-Length: %d" % (len(out_buf)) - print "Content-Type: text/html; Charset: ISO-8859-1" + print "Content-Type: text/html; charset: utf-8" # if there ar additional cookies defined during the request, add them here if webnotes.cookies or webnotes.add_cookies: diff --git a/cgi-bin/webnotes/utils/__init__.py b/cgi-bin/webnotes/utils/__init__.py index f8156046c2..1376ed7d41 100644 --- a/cgi-bin/webnotes/utils/__init__.py +++ b/cgi-bin/webnotes/utils/__init__.py @@ -287,19 +287,13 @@ def cstr(s): """ Convert to string """ - if s==None: + if type(s) in (str, unicode): + return s + elif s==None: return '' else: - if hasattr(s, 'encode'): - try: - s = s.encode('utf-8', 'ignore') - except: - pass - try: - return unicode(s) - except UnicodeDecodeError: - return unicode(s, 'utf-8') - + return str(s) + def str_esc_quote(s): """ Escape quotes diff --git a/js/form.compressed.js b/js/form.compressed.js index b46b5a7095..64ea3993ac 100644 --- a/js/form.compressed.js +++ b/js/form.compressed.js @@ -428,7 +428,7 @@ $c_get_values=function(args,doc,dt,dn,user_callback){var call_back=function(r,rt refresh_field(fl[i],dn,args.table_field);else refresh_field(fl[i]);}} $c('webnotes.widgets.form.get_fields',args,call_back);} -get_server_fields=function(method,arg,table_field,doc,dt,dn,allow_edit,call_back){if(!allow_edit)freeze('Fetching Data...');$c('runserverobj',args={'method':method,'docs':compress_doclist([doc]),'arg':arg},function(r,rt){if(r.message){var d=locals[dt][dn];var field_dict=eval('var a='+r.message+';a');for(var key in field_dict){d[key]=field_dict[key];if(table_field)refresh_field(key,d.name,table_field);else refresh_field(key);}} +get_server_fields=function(method,arg,table_field,doc,dt,dn,allow_edit,call_back){if(!allow_edit)freeze('Fetching Data...');$c('runserverobj',args={'method':method,'docs':compress_doclist([doc]),'arg':arg},function(r,rt){if(r.message){var d=locals[dt][dn];var field_dict=r.message;for(var key in field_dict){d[key]=field_dict[key];if(table_field)refresh_field(key,d.name,table_field);else refresh_field(key);}} if(call_back){doc=locals[doc.doctype][doc.name];call_back(doc,dt,dn);} if(!allow_edit)unfreeze();});} set_multiple=function(dt,dn,dict,table_field){var d=locals[dt][dn];for(var key in dict){d[key]=dict[key];if(table_field)refresh_field(key,d.name,table_field);else refresh_field(key);}} diff --git a/js/utils/handler.js b/js/utils/handler.js index f92bd70403..50a93a626b 100644 --- a/js/utils/handler.js +++ b/js/utils/handler.js @@ -42,7 +42,7 @@ function $c(command, args, fn, on_timeout, no_spinner, freeze_msg) { var rtxt = req.responseText; try { - var r = eval("var a="+rtxt+";a"); + var r = JSON.parse(rtxt); } catch(e) { alert('Handler Exception:' + rtxt); return; diff --git a/js/widgets/form/clientscriptAPI.js b/js/widgets/form/clientscriptAPI.js index ccf64c58c4..f8f37ab06a 100644 --- a/js/widgets/form/clientscriptAPI.js +++ b/js/widgets/form/clientscriptAPI.js @@ -24,8 +24,7 @@ get_server_fields = function(method, arg, table_field, doc, dt, dn, allow_edit, function(r, rt) { if (r.message) { var d = locals[dt][dn]; - var field_dict = eval('var a='+r.message+';a'); - + var field_dict = r.message; for(var key in field_dict) { d[key] = field_dict[key]; if (table_field) refresh_field(key, d.name, table_field); diff --git a/js/wnf.compressed.js b/js/wnf.compressed.js index 11c20e1ccf..95ecd051a4 100644 --- a/js/wnf.compressed.js +++ b/js/wnf.compressed.js @@ -250,7 +250,7 @@ unfreeze();return false;}} var pending_req=0;function newHttpReq(){if(!isIE) var r=new XMLHttpRequest();else if(window.ActiveXObject) var r=new ActiveXObject("Microsoft.XMLHTTP");return r;} -function $c(command,args,fn,on_timeout,no_spinner,freeze_msg){var req=newHttpReq();ret_fn=function(){if(checkResponse(req,on_timeout,no_spinner,freeze_msg)){if(!no_spinner)hide_loading();var rtxt=req.responseText;try{var r=eval("var a="+rtxt+";a");}catch(e){alert('Handler Exception:'+rtxt);return;} +function $c(command,args,fn,on_timeout,no_spinner,freeze_msg){var req=newHttpReq();ret_fn=function(){if(checkResponse(req,on_timeout,no_spinner,freeze_msg)){if(!no_spinner)hide_loading();var rtxt=req.responseText;try{var r=JSON.parse(rtxt);}catch(e){alert('Handler Exception:'+rtxt);return;} if(freeze_msg)unfreeze();if(!validate_session(r,rtxt))return;if(r.exc){errprint(r.exc);};if(r.server_messages){msgprint(r.server_messages);};if(r.docs){LocalDB.sync(r.docs);} saveAllowed=true;if(fn)fn(r,rtxt);}} req.onreadystatechange=ret_fn;req.open("POST",outUrl,true);req.setRequestHeader("ENCTYPE","multipart/form-data");req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");args['cmd']=command;req.send(makeArgString(args));if(!no_spinner)set_loading();if(freeze_msg)freeze(freeze_msg,1);} From 36e7aeb2a552c5380ddf3fd768694fa546ab954e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 12 Aug 2011 11:26:54 +0530 Subject: [PATCH 07/11] doclist.py: catch all if docname does match doc (? unidentified issue) --- cgi-bin/webnotes/model/doclist.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cgi-bin/webnotes/model/doclist.py b/cgi-bin/webnotes/model/doclist.py index 2da46a795e..ee156d6c23 100644 --- a/cgi-bin/webnotes/model/doclist.py +++ b/cgi-bin/webnotes/model/doclist.py @@ -68,6 +68,10 @@ class DocList: self.doc = d else: self.children.append(d) + + # catch all if no self.doc + if not self.doc: + self.doc, self.children = self.docs[0], self.docs[1:] def make_obj(self): """ From dc1d4069661bcdcf31b9780f5fbfd3b3a067fe5e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 12 Aug 2011 11:29:30 +0530 Subject: [PATCH 08/11] doclist.py: catch all if docname does match doc (? unidentified issue) --- cgi-bin/webnotes/model/doclist.py | 1 + cgi-bin/webnotes/profile.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/model/doclist.py b/cgi-bin/webnotes/model/doclist.py index ee156d6c23..c8df02660a 100644 --- a/cgi-bin/webnotes/model/doclist.py +++ b/cgi-bin/webnotes/model/doclist.py @@ -62,6 +62,7 @@ class DocList: self.doc, self.children = self.docs[0], self.docs[1:] else: + self.doc = None self.children = [] for d in self.docs: if d.name == docname: diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index 3fe1eec59d..72b5901c42 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -183,7 +183,7 @@ class Profile: if not (dt in ['Print Format', 'Start Page', 'Event', 'ToDo Item', 'Search Criteria']) and not webnotes.is_testing and not (dt in child_tables): r = cstr(webnotes.conn.sql("select recent_documents from tabProfile where name=%s", self.name)[0][0] or '') - new_str = cstr(dt)+'~~~'+cstr(dn) + '\n' + new_str = dt+'~~~'+dn + '\n' if new_str in r: r = r.replace(new_str, '') From 1638de5295b316ebff0c39d0ce9766cc8f1b1427 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 12 Aug 2011 11:30:45 +0530 Subject: [PATCH 09/11] profile.py: codec --- cgi-bin/webnotes/profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index 72b5901c42..1c4ac13f01 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -182,7 +182,7 @@ class Profile: child_tables = [t[0] for t in conn.sql('select name from tabDocType where istable = 1')] if not (dt in ['Print Format', 'Start Page', 'Event', 'ToDo Item', 'Search Criteria']) and not webnotes.is_testing and not (dt in child_tables): - r = cstr(webnotes.conn.sql("select recent_documents from tabProfile where name=%s", self.name)[0][0] or '') + r = webnotes.conn.sql("select recent_documents from tabProfile where name=%s", self.name)[0][0] or '' new_str = dt+'~~~'+dn + '\n' if new_str in r: r = r.replace(new_str, '') From 67ef4b2ea1a73b175244fd0991720e67491c4c49 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 12 Aug 2011 11:41:49 +0530 Subject: [PATCH 10/11] fixed old recent docs --- cgi-bin/webnotes/profile.py | 25 ++++++++++++++++++------- js/webpage/wntoolbar.js | 26 +++++++++++++++----------- js/wnf.compressed.js | 6 ++++-- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index 1c4ac13f01..963dda4090 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -177,21 +177,32 @@ class Profile: """ conn = webnotes.conn from webnotes.utils import cstr + import json # get list of child tables, so we know what not to add in the recent list child_tables = [t[0] for t in conn.sql('select name from tabDocType where istable = 1')] if not (dt in ['Print Format', 'Start Page', 'Event', 'ToDo Item', 'Search Criteria']) and not webnotes.is_testing and not (dt in child_tables): r = webnotes.conn.sql("select recent_documents from tabProfile where name=%s", self.name)[0][0] or '' - new_str = dt+'~~~'+dn + '\n' - if new_str in r: - r = r.replace(new_str, '') + + # clear old style (to be removed) + if '~~' in r: r = '' + + rdl = json.loads(r or '[]') + new_rd = [dt, dn] + + # clear if exists + for i in range(len(rdl)): + rd = rdl[i] + if rd==new_rd: + del rdl[i] - self.recent = new_str + r - - if len(self.recent.split('\n')) > 50: - self.recent = '\n'.join(self.recent.split('\n')[:50]) + rdl.append(new_rd) + if len(rdl) > 20: + rdl = rdl[:20] + self.recent = json.dumps(rdl) + webnotes.conn.sql("update tabProfile set recent_documents=%s where name=%s", (self.recent, self.name)) def load_profile(self): diff --git a/js/webpage/wntoolbar.js b/js/webpage/wntoolbar.js index 7fbfede1f4..b7bc287a50 100644 --- a/js/webpage/wntoolbar.js +++ b/js/webpage/wntoolbar.js @@ -104,23 +104,27 @@ function WNToolbar(parent) { if(it)$dh(it); if(pscript.on_recent_update)pscript.on_recent_update(); } - // add menu items - var rlist = profile.recent.split('\n'); - var m = rlist.length; - if(m>15)m=15; - for (var i=0;i15)m=15; + for (var i=0;i'+tdn+'' +''+get_doctype_label(dt)+'';var mi=me.menu.add_item('Recent',rec_label,fn,on_top);mi.dt=dt;mi.dn=dn;this.items[dt+'-'+dn]=mi;if(pscript.on_recent_update)pscript.on_recent_update();}} this.rdocs.remove=function(dt,dn){var it=me.rdocs.items[dt+'-'+dn];if(it)$dh(it);if(pscript.on_recent_update)pscript.on_recent_update();} -var rlist=profile.recent.split('\n');var m=rlist.length;if(m>15)m=15;for(var i=0;i15)m=15;for(var i=0;i Date: Tue, 16 Aug 2011 09:08:13 +0530 Subject: [PATCH 11/11] fixes to install + recent --- cgi-bin/webnotes/install_lib/install.py | 14 +++++++++++--- cgi-bin/webnotes/profile.py | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cgi-bin/webnotes/install_lib/install.py b/cgi-bin/webnotes/install_lib/install.py index c270b2059c..68c9fbd2fa 100755 --- a/cgi-bin/webnotes/install_lib/install.py +++ b/cgi-bin/webnotes/install_lib/install.py @@ -98,9 +98,17 @@ class Installer: webnotes.conn.commit() - # - # main script to create a database from - # + def get_db_password(self, db_name): + """ + Get the db_password by method + """ + import webnotes.defs + if hasattr(webnotes.defs, 'get_db_password'): + return webnotes.defs.get_db_password(db_name) + if hasattr(webnotes.defs, 'db_password'): + return webnotes.defs.db_password + return '' + def import_from_db(self, target, source_path='', password = 'admin', verbose=0): """ a very simplified version, just for the time being..will eventually be deprecated once the framework stabilizes. diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index 963dda4090..139243cbbd 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -196,6 +196,7 @@ class Profile: rd = rdl[i] if rd==new_rd: del rdl[i] + break rdl.append(new_rd) if len(rdl) > 20: