diff --git a/cgi-bin/getjsfile.cgi b/cgi-bin/getjsfile.cgi old mode 100644 new mode 100755 diff --git a/cgi-bin/webnotes/model/doc.py b/cgi-bin/webnotes/model/doc.py index b65d4963d3..a3fcbfd0d7 100755 --- a/cgi-bin/webnotes/model/doc.py +++ b/cgi-bin/webnotes/model/doc.py @@ -236,9 +236,6 @@ class Document: # --------------------------------------------------------------------------- def _makenew(self, autoname, istable, case='', make_autoname=1): - # set owner - if not self.owner: self.owner = webnotes.session['user'] - # set name if make_autoname: self._set_name(autoname, istable) @@ -247,7 +244,10 @@ class Document: self._validate_name(case) # insert! - webnotes.conn.sql("""insert into `tab%s` (name, owner, creation, modified, modified_by) values ('%s', '%s', '%s', '%s', '%s')""" % (self.doctype, self.name, webnotes.session['user'], now(), now(), webnotes.session['user'])) + self.owner = self.modified_by = webnotes.session['user'] + self.creation = self.modified = now() + webnotes.conn.sql("""insert into `tab%(doctype)s` (name, owner, creation, modified, modified_by) + values ('%(name)s', '%(owner)s', '%(creation)s', '%(modified)s', '%(modified_by)s')""" % self.fields) # Update Values diff --git a/cgi-bin/webnotes/utils/webservice.py b/cgi-bin/webnotes/utils/webservice.py index 8f72f75203..33b3d175ef 100644 --- a/cgi-bin/webnotes/utils/webservice.py +++ b/cgi-bin/webnotes/utils/webservice.py @@ -41,8 +41,8 @@ class FrameworkServer: webnotes.msgprint(ret) raise Exception, e - if ret.get('message') and ret.get('message')!='Logged In': - raise Exception, ret.get('message') + if 'message' in ret and ret['message']!='Logged In': + webnotes.msgprint(ret.get('server_messages'), raise_exception=1) if ret.get('exc'): raise Exception, ret.get('exc') @@ -90,13 +90,14 @@ class FrameworkServer: """ Returns the response of a remote method called on a system object specified by `doctype` and `docname` """ + import json res = self.http_get_response('runserverobj', args = { 'doctype':doctype ,'docname':docname ,'method':method ,'arg':arg }) - ret = eval(res.read()) + ret = json.loads(res.read()) if ret.get('exc'): raise Exception, ret.get('exc') return ret @@ -104,8 +105,15 @@ class FrameworkServer: # ----------------------------------------------------------------------------------------- def run_method(self, method, args={}): - res = self.http_get_response(method, args) - ret = eval(res.read()) + """ + Run a method on the remote server + """ + res = self.http_get_response(method, args).read() + import json + try: + ret = json.loads(res) + except Exception, e: + webnotes.msgprint('Bad Response: ' + res, raise_exception=1) if ret.get('exc'): raise Exception, ret.get('exc') return ret