Browse Source

fix to js import, now uses scrub for doctype imports

version-14
Rushabh Mehta 14 years ago
parent
commit
d9087a8ae1
2 changed files with 10 additions and 44 deletions
  1. +9
    -43
      cgi-bin/webnotes/__init__.py
  2. +1
    -1
      cgi-bin/webnotes/modules/__init__.py

+ 9
- 43
cgi-bin/webnotes/__init__.py View File

@@ -139,57 +139,23 @@ def create_folder(path):
raise e


###############################################################################
# BEGIN: TENTATIVE CODE FEELS LIKE A CLASS/TEMPLATE IS A BETTER IDEA FOR THESE VARIABLES.
# Bad idea combining/using one function to set conn,user,session variables.
# Need to split up.
###############################################################################
def connect(db_name):
"""
Connect to this db (or db), if called from command prompt
"""
if is_apache_user():
raise Exception, 'Not for web users!'

def set_as_account_master():
import webnotes.db
global conn
conn = webnotes.db.Database(use_default = 1)

def set_as_administrator():
global user
conn = webnotes.db.Database(db_name=db_name)
if is_apache_user():
raise Exception, 'Not for web users!'

import webnotes.profile
user = webnotes.profile.Profile('Administrator')

def set_as_admin_session():
global session
session = {'user':'Administrator'}

###############################################################################
#END
###############################################################################


def set_as_admin(db_name=None, ac_name=None):

import os
if is_apache_user():
raise Exception, 'Not for web users!'

global conn
global session
global user
import webnotes.db
if ac_name:
conn = webnotes.db.Database(ac_name = ac_name)
else:
set_as_account_master()
if db_name:
conn.use(db_name)
session = {'user':'Administrator'}
import webnotes.profile
user = webnotes.profile.Profile('Administrator')
global user
user = webnotes.profile.Profile('Administrator')


# Environment Variables


+ 1
- 1
cgi-bin/webnotes/modules/__init__.py View File

@@ -312,7 +312,7 @@ class JsModuleFile(ModuleFile):
path = os.path.join(Module(module).get_path(), os.path.sep.join(name.split(os.path.sep)[1:]))
else:
# its a doctype
path = os.path.join(get_doc_path('DocType', name), name + '.js')
path = os.path.join(get_doc_path('DocType', name), scrub(name) + '.js')
return JsModuleFile(path).read()


Loading…
Cancel
Save