Pārlūkot izejas kodu

Fix: InterfaceError due to use of old webnotes.conn when specifying sql = webnotes.conn.sql at the start of module rather than in the function itself

version-14
Anand Doshi pirms 13 gadiem
vecāks
revīzija
076e05bc98
6 mainītis faili ar 15 papildinājumiem un 10 dzēšanām
  1. +1
    -2
      py/core/doctype/control_panel/control_panel.py
  2. +5
    -4
      py/core/doctype/custom_field/custom_field.py
  3. +3
    -1
      py/core/doctype/doctype/doctype.py
  4. +1
    -1
      py/core/doctype/search_criteria/search_criteria.py
  5. +4
    -1
      py/webnotes/db.py
  6. +1
    -1
      py/webnotes/utils/scheduler.py

+ 1
- 2
py/core/doctype/control_panel/control_panel.py Parādīt failu

@@ -6,7 +6,6 @@ from webnotes.model.doc import Document
from webnotes.model.code import get_obj
from webnotes import session, form, is_testing, msgprint, errprint

sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
# -----------------------------------------------------------------------------------------
@@ -19,7 +18,7 @@ class DocType:

def on_update(self):
# clear cache on save
sql("delete from __SessionCache")
webnotes.conn.sql("delete from __SessionCache")

def upload_many(self,form):
pass


+ 5
- 4
py/core/doctype/custom_field/custom_field.py Parādīt failu

@@ -5,11 +5,7 @@ from webnotes.utils import cint, cstr, flt, formatdate, now
from webnotes.model.doc import Document
from webnotes import msgprint, errprint

sql = webnotes.conn.sql
# -----------------------------------------------------------------------------------------


class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
@@ -17,6 +13,7 @@ class DocType:
# Get Fields
# -----------
def get_fields_label(self):
sql = webnotes.conn.sql
label_name = []
for i in sql("SELECT idx, label FROM tabDocField WHERE parent = '%s' and ifnull(hidden,0) = 0 and fieldname != '%s' order by idx" % (self.doc.dt, cstr(self.doc.fieldname))): i[1] and i[0] and label_name.append(i[1]+' - '+cstr(i[0]))
return "\n".join(label_name)
@@ -34,6 +31,7 @@ class DocType:
# Validate Field
# ---------------
def validate_field(self):
sql = webnotes.conn.sql
if self.doc.__islocal == 1 and sql("select name from tabDocField where parent = %s and (label = %s or fieldname = %s)" , (self.doc.dt, self.doc.label, self.doc.fieldname)):
msgprint("%s field already exists in Document : %s" % (self.doc.label, self.doc.dt))
raise Exception
@@ -47,6 +45,7 @@ class DocType:
# Update Field
# -------------
def update_field(self, df, new):
sql = webnotes.conn.sql
import webnotes.model
sql("update tabDocField set idx = idx + 1, modified = %s where parent = %s and idx > %s", (now(),self.doc.dt, self.idx))
for k in self.doc.fields:
@@ -62,6 +61,7 @@ class DocType:
# Add Field
# ----------
def add_field(self):
sql = webnotes.conn.sql
field_exists = sql("select name from tabDocField where parent = %s and (label = %s or fieldname = %s)" , (self.doc.dt, self.doc.label, self.doc.fieldname))
field_exists = field_exists and field_exists[0][0] or ''
self.ignore_fields = ['dt','trash_reason','insert_after','index','customfield1','length']
@@ -88,6 +88,7 @@ class DocType:
# Trash
# ------
def on_trash(self):
sql = webnotes.conn.sql
sql("update tabDocField set idx = idx - 1 where parent = %s and idx > %s" , (self.doc.dt, cint((self.doc.insert_after).split(' - ')[1])))
sql("delete from tabDocField where parent = %s and fieldname = %s", (self.doc.dt, self.doc.fieldname))



+ 3
- 1
py/core/doctype/doctype/doctype.py Parādīt failu

@@ -2,7 +2,6 @@
import webnotes

from webnotes.utils import now, cint
sql = webnotes.conn.sql
msgprint = webnotes.msgprint


@@ -15,6 +14,7 @@ class DocType:
self.doclist = doclist

def change_modified_of_parent(self):
sql = webnotes.conn.sql
parent_list = sql('SELECT parent from tabDocField where fieldtype="Table" and options="%s"' % self.doc.name)
for p in parent_list:
sql('UPDATE tabDocType SET modified="%s" WHERE `name`="%s"' % (now(), p[0]))
@@ -35,6 +35,7 @@ class DocType:
# check if this series is not used elsewhere
#
def validate_series(self, autoname=None, name=None):
sql = webnotes.conn.sql
if not autoname: autoname = self.doc.autoname
if not name: name = self.doc.name
@@ -73,6 +74,7 @@ class DocType:


def on_update(self):
sql = webnotes.conn.sql
# make schma changes
from webnotes.model.db_schema import updatedb
updatedb(self.doc.name)


+ 1
- 1
py/core/doctype/search_criteria/search_criteria.py Parādīt failu

@@ -49,7 +49,7 @@ class DocType:
self.set_module()
self.autoname()
sql("update `tabSearch Criteria` set name=%s where name=%s", (self.doc.name, old_name))
webnotes.conn.sql("update `tabSearch Criteria` set name=%s where name=%s", (self.doc.name, old_name))
def rename_export(self, old_name):


+ 4
- 1
py/webnotes/db.py Parādīt failu

@@ -124,7 +124,7 @@ class Database:
* Execute a `query`, with given `values`
* returns as a dictionary if as_dict = 1
* returns as a list of lists (with cleaned up dates and decimals) if as_list = 1
"""
"""
# in transaction validations
self.check_transaction_status(query)
@@ -340,4 +340,7 @@ class Database:
Close my connection
"""
if self._conn:
self._cursor.close()
self._conn.close()
self._cursor = None
self._conn = None

+ 1
- 1
py/webnotes/utils/scheduler.py Parādīt failu

@@ -92,9 +92,9 @@ class Scheduler:
import webnotes, webnotes.defs, webnotes.db

try:
webnotes.conn = None
webnotes.conn = webnotes.db.Database(user=db_name, password=webnotes.get_db_password(db_name))
webnotes.session = {'user':'Administrator'}

module = '.'.join(event.split('.')[:-1])
method = event.split('.')[-1]


Notiek ielāde…
Atcelt
Saglabāt