From e7462499d92972b20fef01f7b266257679e79c42 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 27 Jun 2011 10:58:32 +0530 Subject: [PATCH 1/8] fix to install.py --- cgi-bin/webnotes/install_lib/install.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cgi-bin/webnotes/install_lib/install.py b/cgi-bin/webnotes/install_lib/install.py index 2a014b4398..e4791b66e9 100755 --- a/cgi-bin/webnotes/install_lib/install.py +++ b/cgi-bin/webnotes/install_lib/install.py @@ -21,6 +21,9 @@ def copy_defs(): # class Installer: def __init__(self, root_login, root_password): + + import webnotes + import webnotes.db self.root_password = root_password from webnotes.model.db_schema import DbManager @@ -35,6 +38,8 @@ class Installer: # run framework related cleanups # def framework_cleanups(self, target): + + import webnotes self.dbman.drop_table('__DocTypeCache') webnotes.conn.sql("create table `__DocTypeCache` (name VARCHAR(120), modified DATETIME, content TEXT, server_code_compiled TEXT)") @@ -48,6 +53,7 @@ class Installer: Imports the "Core" module from .txt file and creates Creates profile Administrator """ + import webnotes from webnotes.modules.import_module import import_module from webnotes.modules.module_manager import reload_doc From 5033f1f36488d13fd4b1fc1c73502454bd4a6e70 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 27 Jun 2011 11:02:52 +0530 Subject: [PATCH 2/8] fixes in install --- cgi-bin/webnotes/install_lib/install.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cgi-bin/webnotes/install_lib/install.py b/cgi-bin/webnotes/install_lib/install.py index e4791b66e9..dc720bdfa6 100755 --- a/cgi-bin/webnotes/install_lib/install.py +++ b/cgi-bin/webnotes/install_lib/install.py @@ -24,6 +24,7 @@ class Installer: import webnotes import webnotes.db + import webnotes.defs self.root_password = root_password from webnotes.model.db_schema import DbManager @@ -32,7 +33,7 @@ class Installer: webnotes.conn=self.conn webnotes.session= {'user':'Administrator'} self.dbman = DbManager(self.conn) - self.mysql_path = hasattr(defs, 'mysql_path') and webnotes.defs.mysql_path or '' + self.mysql_path = hasattr(webnotes.defs, 'mysql_path') and webnotes.defs.mysql_path or '' # # run framework related cleanups @@ -101,6 +102,7 @@ class Installer: """ a very simplified version, just for the time being..will eventually be deprecated once the framework stabilizes. """ + import webnotes.defs #Storing passed source path passed_source_path = source_path @@ -113,7 +115,7 @@ class Installer: self.dbman.delete_user(target) # create user and db - self.dbman.create_user(target,getattr(defs,'db_password',None)) + self.dbman.create_user(target,getattr(webnotes.defs,'db_password',None)) if verbose: print "Created user %s" % target # create a database @@ -159,7 +161,7 @@ def make_scheduler(root_login, root_password, verbose): dbman.delete_user('master_scheduler') # create user and db - dbman.create_user('master_scheduler', getattr(defs,'db_password',None)) + dbman.create_user('master_scheduler', getattr(webnotes.defs,'db_password',None)) if verbose: print "Created user master_scheduler" # create a database @@ -215,14 +217,14 @@ if __name__=='__main__': try: - from webnotes import defs import webnotes import webnotes.db + import webnotes.defs except ImportError: copy_defs() - from webnotes import defs import webnotes import webnotes.db + import webnotes.defs if len(args)==3: From 74720f659f9549e119a82860418df99adb88f088 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 27 Jun 2011 11:23:28 +0530 Subject: [PATCH 3/8] space allowed in db password --- cgi-bin/webnotes/install_lib/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/install_lib/install.py b/cgi-bin/webnotes/install_lib/install.py index dc720bdfa6..b54db527e8 100755 --- a/cgi-bin/webnotes/install_lib/install.py +++ b/cgi-bin/webnotes/install_lib/install.py @@ -133,7 +133,7 @@ class Installer: # import in target if verbose: print "Starting database import..." - self.dbman.restore_database(target, source_path, self.root_password) + self.dbman.restore_database(target, source_path, self.root_password.replace(' ','\ ')) if verbose: print "Imported from database %s" % source_path #If source path is passed From 9fcb4c230fd35936129defa78a53a5e7f96c608f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 27 Jun 2011 12:33:39 +0530 Subject: [PATCH 4/8] bug fix in core/doctype/profile naming --- cgi-bin/core/doctype/profile/profile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cgi-bin/core/doctype/profile/profile.py b/cgi-bin/core/doctype/profile/profile.py index 60388f039f..d4684a7bf3 100644 --- a/cgi-bin/core/doctype/profile/profile.py +++ b/cgi-bin/core/doctype/profile/profile.py @@ -25,7 +25,8 @@ class DocType: if not validate_email_add(self.doc.email): msgprint("%s is not a valid email id" % self.doc.email) raise Exception - self.doc.name = self.doc.email + + self.doc.name = self.doc.email def on_update(self): # owner is always name From 923a1e5447ecefa0d5175141a1e949ba4daadd47 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 27 Jun 2011 16:39:03 +0530 Subject: [PATCH 5/8] validate criteria name --- .gitignore | 3 +++ .../search_criteria/search_criteria.py | 3 +++ cgi-bin/webnotes/install_lib/install.py | 20 ++++++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..117b892b34 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.pyc +*.comp.js +*.DS_Store diff --git a/cgi-bin/core/doctype/search_criteria/search_criteria.py b/cgi-bin/core/doctype/search_criteria/search_criteria.py index 2acbc16c3b..b9b5d3c84c 100644 --- a/cgi-bin/core/doctype/search_criteria/search_criteria.py +++ b/cgi-bin/core/doctype/search_criteria/search_criteria.py @@ -26,6 +26,9 @@ class DocType: doctype_module = sql("select module from tabDocType where name = '%s'" % (self.doc.doc_type)) webnotes.conn.set(self.doc,'module',doctype_module and doctype_module[0][0] or 'NULL') + def validate(self): + sql("select name from `tabSearch Criteria` where criteria_name=%s and name!=%s", (self.doc.criteria_name, self.doc.name)) + def on_update(self): self.set_module() self.export_doc() diff --git a/cgi-bin/webnotes/install_lib/install.py b/cgi-bin/webnotes/install_lib/install.py index 5612f36ce2..c801f4720f 100755 --- a/cgi-bin/webnotes/install_lib/install.py +++ b/cgi-bin/webnotes/install_lib/install.py @@ -57,6 +57,10 @@ class Installer: import_module('core') + def create_users(self): + """ + Create Administrator / Guest + """ webnotes.conn.begin() from webnotes.model.doc import Document @@ -96,10 +100,6 @@ class Installer: a very simplified version, just for the time being..will eventually be deprecated once the framework stabilizes. """ - # get the path of the sql file to import - if not source_path: - source_path = os.path.join(os.path.sep.join(os.path.abspath(webnotes.__file__).split(os.path.sep)[:-3]), 'data', 'Framework.sql') - # delete user (if exists) self.dbman.delete_user(target) @@ -122,10 +122,20 @@ class Installer: # import in target if verbose: print "Starting database import..." + + # get the path of the sql file to import + source_given = True + if not source_path: + source_given = False + source_path = os.path.join(os.path.sep.join(os.path.abspath(webnotes.__file__).split(os.path.sep)[:-3]), 'data', 'Framework.sql') + self.dbman.restore_database(target, source_path, self.root_password) if verbose: print "Imported from database %s" % source_path - self.import_core_module() + if not source_given: + if verbose: print "Importing core module..." + self.import_core_module() + self.create_users() # framework cleanups self.framework_cleanups(target) From ca6e0771a9523219f38f80d6b3f3c0f2492e75e8 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 27 Jun 2011 16:40:19 +0530 Subject: [PATCH 6/8] validate criteria name --- cgi-bin/core/doctype/search_criteria/search_criteria.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cgi-bin/core/doctype/search_criteria/search_criteria.py b/cgi-bin/core/doctype/search_criteria/search_criteria.py index b9b5d3c84c..00e5eb4330 100644 --- a/cgi-bin/core/doctype/search_criteria/search_criteria.py +++ b/cgi-bin/core/doctype/search_criteria/search_criteria.py @@ -27,7 +27,8 @@ class DocType: webnotes.conn.set(self.doc,'module',doctype_module and doctype_module[0][0] or 'NULL') def validate(self): - sql("select name from `tabSearch Criteria` where criteria_name=%s and name!=%s", (self.doc.criteria_name, self.doc.name)) + if sql("select name from `tabSearch Criteria` where criteria_name=%s and name!=%s", (self.doc.criteria_name, self.doc.name)): + webnots.msgprint("Criteria Name '%s' already used, please use another name" % self.doc.criteria_name, raise_exception = 1) def on_update(self): self.set_module() From 3ee3a7ef4d01657227e7cc40e8696deaa6607f39 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 28 Jun 2011 21:10:05 +0530 Subject: [PATCH 7/8] form style and module fixes --- cgi-bin/webnotes/modules/__init__.py | 26 +++++++++++++++++++++- cgi-bin/webnotes/modules/module_manager.py | 24 -------------------- js/form.compressed.js | 2 +- js/widgets/form/form_container.js | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cgi-bin/webnotes/modules/__init__.py b/cgi-bin/webnotes/modules/__init__.py index 665c77013c..62efefc36a 100644 --- a/cgi-bin/webnotes/modules/__init__.py +++ b/cgi-bin/webnotes/modules/__init__.py @@ -62,4 +62,28 @@ def get_module_path(module): # get module path by importing the module modules_path = os.path.join(webnotes.defs.modules_path, scrub(module)) - return modules_path \ No newline at end of file + return modules_path + +def switch_module(dt, dn, to, frm=None, export=None): + """ + Change the module of the given doctype, if export is true, then also export txt and copy + code files from src + """ + import os + webnotes.conn.sql("update `tab"+dt+"` set module=%s where name=%s", (to, dn)) + + if export: + export_doc(dt, dn) + + # copy code files + if dt in ('DocType', 'Page', 'Search Criteria'): + from_path = os.path.join(get_module_path(frm), scrub(dt), scrub(dn), scrub(dn)) + to_path = os.path.join(get_module_path(to), scrub(dt), scrub(dn), scrub(dn)) + + # make dire if exists + os.system('mkdir -p %s' % os.path.join(get_module_path(to), scrub(dt), scrub(dn))) + + for ext in ('py','js','html','css'): + os.system('cp %s %s') + + diff --git a/cgi-bin/webnotes/modules/module_manager.py b/cgi-bin/webnotes/modules/module_manager.py index 90679df0b2..c166646bff 100644 --- a/cgi-bin/webnotes/modules/module_manager.py +++ b/cgi-bin/webnotes/modules/module_manager.py @@ -1,27 +1,3 @@ -#============================================================================== -# script to change the module name in the database & update svn -#============================================================================== - -def change_module(dt, dn, from_module, to_module): - import os, webnotes.defs - from webnotes.modules import scrub - - # change in db - webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % (dt, '%s', '%s'), (to_module, dn)) - - # export files - from webnotes.modules.export_module import export_to_files - export_to_files(record_list = [[dt, dn]]) - - if dt in ['DocType','Page','Search Criteria']: - dt, dn = scrub(dt), scrub(dn) - - # svn add - webnotes.msgprint(os.popen("svn add %s" % os.path.join(webnotes.defs.modules_path, scrub(to_module), dt, dn)).read()) - - # svn remove - webnotes.msgprint(os.popen("svn remove %s" % os.path.join(webnotes.defs.modules_path, scrub(from_module), dt, dn)).read()) - #============================================================================== diff --git a/js/form.compressed.js b/js/form.compressed.js index 3ebd877383..32c2369634 100644 --- a/js/form.compressed.js +++ b/js/form.compressed.js @@ -1,5 +1,5 @@ -_f.FrmContainer=function(){this.wrapper=page_body.add_page("Forms",function(){},function(){});this.last_displayed=null;$dh(this.wrapper);this.body=$a(this.wrapper,'div');_f.frm_dialog=new _f.FrmDialog();} +_f.FrmContainer=function(){this.wrapper=page_body.add_page("Forms",function(){},function(){});this.last_displayed=null;$dh(this.wrapper);this.body=$a(this.wrapper,'div','frm_container');_f.frm_dialog=new _f.FrmDialog();} _f.frm_dialog=null;_f.calling_doc_stack=[];_f.temp_access={};_f.FrmDialog=function(){var me=this;this.last_displayed=null;var d=new Dialog(640,null,'Edit Row');this.body=$a(d.body,'div','dialog_frm');$y(d.body,{backgroundColor:'#EEE'});d.done_btn_area=$a(d.body,'div','',{margin:'8px'});me.on_complete=function(){if(me.table_form){me.dialog.hide();}else{var callback=function(r){var dn=cur_frm.docname;if(!r.exc){me.dialog.hide();} if(me.on_save_callback) me.on_save_callback(dn);} diff --git a/js/widgets/form/form_container.js b/js/widgets/form/form_container.js index 980b952419..eacd237e37 100644 --- a/js/widgets/form/form_container.js +++ b/js/widgets/form/form_container.js @@ -5,7 +5,7 @@ _f.FrmContainer = function() { // create hidden $dh(this.wrapper); - this.body = $a(this.wrapper,'div'); + this.body = $a(this.wrapper,'div','frm_container'); // make by twin _f.frm_dialog = new _f.FrmDialog(); From fcd77ee512cb9a8fe4fecf0ee10da2880dcf7e09 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 29 Jun 2011 11:32:34 +0530 Subject: [PATCH 8/8] addes tests and cleaned up export_module --- cgi-bin/webnotes/__init__.py | 3 + cgi-bin/webnotes/modules/export_module.py | 194 +++--------------- cgi-bin/webnotes/settings/__init__.py | 0 .../webnotes/settings/account_map_template.py | 10 - cgi-bin/webnotes/tests.py | 64 ++++++ index.cgi | 2 +- 6 files changed, 92 insertions(+), 181 deletions(-) delete mode 100644 cgi-bin/webnotes/settings/__init__.py delete mode 100644 cgi-bin/webnotes/settings/account_map_template.py create mode 100644 cgi-bin/webnotes/tests.py diff --git a/cgi-bin/webnotes/__init__.py b/cgi-bin/webnotes/__init__.py index 8607425ffb..f96c91dbf1 100644 --- a/cgi-bin/webnotes/__init__.py +++ b/cgi-bin/webnotes/__init__.py @@ -125,6 +125,9 @@ def get_files_path(): return os.path.join(get_index_path(), 'user_files', conn.cur_db_name) def create_folder(path): + """ + Wrapper function for os.makedirs (does not throw exception if directory exists) + """ import os try: diff --git a/cgi-bin/webnotes/modules/export_module.py b/cgi-bin/webnotes/modules/export_module.py index b1232bd316..9465a2d036 100644 --- a/cgi-bin/webnotes/modules/export_module.py +++ b/cgi-bin/webnotes/modules/export_module.py @@ -1,165 +1,27 @@ -# ============================================================================== -# export to files -# ============================================================================== - -updated_modules = [] - from webnotes.modules import scrub, get_module_path -def export_to_files(modules = [], record_list=[], from_db=None, from_ac=None, verbose=1, record_module=None): - # Multiple doctype and multiple modules export to be done - # for Module Def, right now using a hack..should consider table update in the next version - # all modules transfer not working, because source db not known - # get the items - - global updated_modules - - if from_ac or from_db: - init_db_login(from_ac, from_db) - - out = [] - import webnotes.model.doc +def export_to_files(record_list=[], record_module=None, verbose=0): module_doclist =[] if record_list: for record in record_list: - module_doclist.append([d.fields for d in webnotes.model.doc.get(record[0], record[1])]) - - # build the doclist - if modules: - for m in modules: - module_doclist +=get_module_doclist(m) - - # write files - for doclist in module_doclist: - if verbose: - out.append("Writing for " + doclist[0]['doctype'] + " / " + doclist[0]['name']) - write_document_file(doclist, record_module) - - # write out attachments - for m in modules: - write_attachments(m) - + doclist = [d.fields for d in webnotes.model.doc.get(record[0], record[1])] + write_document_file(doclist, record_module) + return out -# ============================================================================== -# write module.info file with last updated timestamp -# ============================================================================== - -def write_attachments(m): - import webnotes, os - from webnotes.utils.file_manager import get_file - - try: - fl = webnotes.conn.sql("select name from `tabFile Data` where module=%s", m) - except Exception, e: - if e.args[0]==1054: # no field called module - return - else: - raise e - - # write the files - if fl: - folder = os.path.join(webnotes.defs.modules_path, m, 'files') - webnotes.create_folder(folder) - for f in fl: - file_det = get_file(f) - file = open(os.path.join(folder, file_det[0]), 'w+') - file.write(file_det[1]) - file.close() - - -# ============================================================================== -# write module.info file with last updated timestamp -# ============================================================================== - -def write_module_info(mod): - import webnotes.utils, os - - file = open(os.path.join(get_module_path(mod), 'module.info'), 'w') - file.write(str({'update_date': webnotes.utils.now()})) - file.close() - -# ============================================================================== -# prepare a list of items in a module -# ============================================================================== - -def get_module_items(mod): - import webnotes - from webnotes.modules import transfer_types - from webnotes.modules import scrub - - dl = [] - for dt in transfer_types: - try: - dl2 = webnotes.conn.sql('select name, modified from `tab%s` where module="%s"' % (dt,mod)) - for e in dl2: - dl += [dt + ',' + e[0] + ',0'] - - if e[0] == 'Control Panel': - dl += [e[0]+','+e[0]+',1'] - except: - pass - dl1 = webnotes.conn.sql('select doctype_list from `tabModule Def` where name=%s', mod) - dl1 = dl1 and dl1[0][0] or '' - if dl1: - dl1 = dl1.split('\n') - dl += [t+',1' for t in dl1] - dl += ['Module Def,'+mod+',0'] - # build finally - dl = [e.split(',') for e in dl] - dl = [[e[0].strip(), e[1].strip(), e[2]] for e in dl] # remove blanks - return dl - - -# ============================================================================== -# build a list of doclists of items in that module and send them -# ============================================================================== - -def get_module_doclist(module): - import webnotes - import webnotes.model.doc - item_list = get_module_items(module) - - # build the super_doclist - super_doclist = [] - for i in item_list: - dl = webnotes.model.doc.get(i[0], i[1]) - if i[2]=='1': - dl[0].module = module - # remove compiled code (if any) - if dl[0].server_code_compiled: - dl[0].server_code_compiled = None - - # add to super - super_doclist.append([d.fields for d in dl]) - - return super_doclist - -# ============================================================================== -# Create __init__.py files -# ============================================================================== - -def create_init_py(modules_path, dt, dn): +def create_init_py(modules_path, module, dt, dn): import os from webnotes.modules import scrub - # in module - if not '__init__.py' in os.listdir(modules_path): - open(os.path.join(modules_path, '__init__.py'), 'w').close() - - # in type and name folders - if dt in ['doctype', 'page', 'search_criteria']: - if not '__init__.py' in os.listdir(os.path.join(modules_path, dt)): - open(os.path.join(modules_path, dt, '__init__.py'), 'w').close() - - if not '__init__.py' in os.listdir(os.path.join(modules_path, dt, dn)): - open(os.path.join(modules_path, dt, dn, '__init__.py'), 'w').close() - - -# ============================================================================== -# Create module folders -# ============================================================================== - + def create_if_not_exists(path): + initpy = os.path.join(path, '__init__.py') + if not os.path.exists(initpy): + open(initpy, 'w').close() + + create_if_not_exists(os.path.join(modules_path, module)) + create_if_not_exists(os.path.join(modules_path, module, dt)) + create_if_not_exists(os.path.join(modules_path, module, dt, dn)) + def create_folder(module, dt, dn): import webnotes, os @@ -175,31 +37,28 @@ def create_folder(module, dt, dn): # create init_py_files if code_type: - create_init_py(modules_path, scrub(dt), scrub(dn)) + create_init_py(modules_path, module, scrub(dt), scrub(dn)) return folder -# ============================================================================== -# Write doclist into file -# ============================================================================== - -def write_document_file(doclist, record_module=None): - import os - from webnotes.utils import pprint_dict - - global updated_modules - +def get_module_name(doclist, record_module=None): # module name if doclist[0]['doctype'] == 'Module Def': module = doclist[0]['name'] elif doclist[0]['doctype']=='Control Panel': - module = 'System' + module = 'Core' elif record_module: module = record_module else: module = doclist[0]['module'] - updated_modules.append(module) + return module + +def write_document_file(doclist, record_module=None): + import os + from webnotes.utils import pprint_dict + + module = get_module_name() # create the folder code_type = doclist[0]['doctype'] in ['DocType','Page','Search Criteria'] @@ -218,11 +77,6 @@ def write_document_file(doclist, record_module=None): txtfile.write('[\n' + ',\n'.join(dict_list) + '\n]') txtfile.close() - -# ============================================================================== -# Create seperate files for code -# ============================================================================== - def clear_code_fields(doclist, folder, code_type): import os diff --git a/cgi-bin/webnotes/settings/__init__.py b/cgi-bin/webnotes/settings/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cgi-bin/webnotes/settings/account_map_template.py b/cgi-bin/webnotes/settings/account_map_template.py deleted file mode 100644 index dd634cd2ba..0000000000 --- a/cgi-bin/webnotes/settings/account_map_template.py +++ /dev/null @@ -1,10 +0,0 @@ -# Account/Domain Name to Database Mapping file -# -------------------------------------------- -# last updated on: 2011-02-02 14:31:14 - -default_db_name = "webnotesdb" - -db_name_map = {'wnframework':'webnotesdb'} -#{'main_acc_name';'db_name'} -domain_name_map = {'localhost':'webnotesdb'} - diff --git a/cgi-bin/webnotes/tests.py b/cgi-bin/webnotes/tests.py new file mode 100644 index 0000000000..36d944bb68 --- /dev/null +++ b/cgi-bin/webnotes/tests.py @@ -0,0 +1,64 @@ +""" +Run tests from modules. Sets up database connection, modules path and session before running test + +Usage: from shell, run + +python tests.py [test modules] + +Options: + test modules: list of modules separated by space + +if no modules are specified, it will run all "tests.py" files from all modules +""" + +import sys, os +import unittest + +# webnotes path +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + +# modules path +import webnotes +import webnotes.defs + +if webnotes.defs.__dict__.get('modules_path'): + sys.path.append(webnotes.defs.modules_path) + +def get_tests(): + """ + Returns list of test modules identified by "tests.py" + """ + ret = [] + for walk_tuple in os.walk(webnotes.defs.modules_path): + if 'tests.py' in walk_tuple[2]: + dir_path = os.path.relpath(walk_tuple[0], webnotes.defs.modules_path) + if dir_path=='.': + ret.append('tests') + else: + ret.append(dir_path.replace('/', '.') + '.tests') + + return ret + +def setup(): + """ + Sets up connection and session + """ + from webnotes.db import Database + webnotes.conn = Database() + webnotes.session = {'user':'Administrator'} + +if __name__=='__main__': + setup() + + if len(sys.argv) > 1: + tests_list = sys.argv[1:] + + # for unittest.main + sys.argv = sys.argv[:1] + else: + tests_list = get_tests() + + for tests in tests_list: + exec 'from %s import *' % str(tests) + + unittest.main() \ No newline at end of file diff --git a/index.cgi b/index.cgi index 5e19f28ea4..92615a83e9 100755 --- a/index.cgi +++ b/index.cgi @@ -10,7 +10,7 @@ try: import sys, os, cgi - sys.path.append(os.getcwd()+'/cgi-bin') + sys.path.append(os.path.join(os.path.dirname(__file__), 'cgi-bin')) import webnotes import webnotes.defs