Explorar el Código

fixes to doc.py and webservice.py

version-14
Rushabh Mehta hace 14 años
padre
commit
6466d65082
Se han modificado 2 ficheros con 17 adiciones y 9 borrados
  1. +4
    -4
      cgi-bin/webnotes/model/doc.py
  2. +13
    -5
      cgi-bin/webnotes/utils/webservice.py

+ 4
- 4
cgi-bin/webnotes/model/doc.py Ver fichero

@@ -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


+ 13
- 5
cgi-bin/webnotes/utils/webservice.py Ver fichero

@@ -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

Cargando…
Cancelar
Guardar