Bladeren bron

[install] fixes - do not update parent doctype if in_import

version-14
Rushabh Mehta 12 jaren geleden
bovenliggende
commit
a49e82508c
4 gewijzigde bestanden met toevoegingen van 21 en 10 verwijderingen
  1. +6
    -3
      core/doctype/doctype/doctype.py
  2. +3
    -1
      webnotes/install_lib/install.py
  3. +3
    -3
      webnotes/model/sync.py
  4. +9
    -3
      webnotes/modules/import_file.py

+ 6
- 3
core/doctype/doctype/doctype.py Bestand weergeven

@@ -34,10 +34,13 @@ 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)
if webnotes.in_import:
return
parent_list = webnotes.conn.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]))
webnotes.conn.sql('''UPDATE tabDocType SET modified="%s"
WHERE `name`="%s"''' % (now(), p[0]))

def scrub_field_names(self):
restricted = ('name','parent','idx','owner','creation','modified','modified_by',


+ 3
- 1
webnotes/install_lib/install.py Bestand weergeven

@@ -104,6 +104,7 @@ class Installer:
self.import_core_docs()
install.pre_import()
sync_for("app", force=True, sync_everything=True)

print "Completing App Import..."
install.post_import()
print "Updating patches..."
@@ -169,7 +170,8 @@ class Installer:
webnotes.conn.commit()

def create_auth_table(self):
webnotes.conn.sql("""create table if not exists __Auth (
webnotes.conn.sql("""drop table if exists __Auth""")
webnotes.conn.sql("""create table __Auth (
`user` VARCHAR(180) NOT NULL PRIMARY KEY,
`password` VARCHAR(180) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8""")

+ 3
- 3
webnotes/model/sync.py Bestand weergeven

@@ -6,7 +6,7 @@ from __future__ import unicode_literals
import webnotes
import os
import conf
from webnotes.modules import reload_doc
from webnotes.modules.import_file import import_file

def sync_all(force=0):
sync_for("lib", force)
@@ -38,9 +38,9 @@ def walk_and_sync(start_path, force=0, sync_everything = False):
doctype = path.split(os.sep)[-2]
name = path.split(os.sep)[-1]
if reload_doc(module_name, doctype, name, force):
if import_file(module_name, doctype, name, force):
print module_name + ' | ' + doctype + ' | ' + name

webnotes.conn.commit()
return modules

+ 9
- 3
webnotes/modules/import_file.py Bestand weergeven

@@ -27,8 +27,10 @@ from webnotes.modules import scrub, get_module_path, scrub_dt_dn

def import_files(module, dt=None, dn=None, force=False):
if type(module) is list:
out = []
for m in module:
return import_file(m[0], m[1], m[2], force)
out.append(import_file(m[0], m[1], m[2], force))
return out
else:
return import_file(module, dt, dn, force)
@@ -49,20 +51,24 @@ def import_file_by_path(path, force=False):
with open(path, 'r') as f:
doclist = peval_doclist(f.read())
if doclist:
doc = doclist[0]
if not force:
# check if timestamps match
if doc['modified']== str(webnotes.conn.get_value(doc['doctype'], doc['name'], 'modified')):
return False
original_modified = doc["modified"]
import_doclist(doclist)

# since there is a new timestamp on the file, update timestamp in
webnotes.conn.sql("update `tab%s` set modified=%s where name=%s" % \
(doc['doctype'], '%s', '%s'),
(doc['modified'],doc['name']))
(original_modified, doc['name']))

return True
else:
raise Exception, '%s missing' % path


Laden…
Annuleren
Opslaan