# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) # # MIT License (MIT) # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # """ globals attached to webnotes module + some utility functions that should probably be moved """ code_fields_dict = { 'Page':[('script', 'js'), ('content', 'html'), ('style', 'css'), ('static_content', 'html'), ('server_code', 'py')], 'DocType':[('server_code_core', 'py'), ('client_script_core', 'js')], 'Search Criteria':[('report_script', 'js'), ('server_script', 'py'), ('custom_query', 'sql')], 'Patch':[('patch_code', 'py')], 'Stylesheet':['stylesheet', 'css'], 'Page Template':['template', 'html'], 'Control Panel':[('startup_code', 'js'), ('startup_css', 'css')] } version = 'v170' form_dict = {} auth_obj = None conn = None form = None session = None user = None is_testing = None incoming_cookies = {} add_cookies = {} # append these to outgoing request cookies = {} auto_masters = {} tenant_id = None response = {'message':'', 'exc':''} debug_log = [] message_log = [] class ValidationError(Exception): pass class AuthenticationError(Exception): pass class PermissionError(Exception): pass class OutgoingEmailError(ValidationError): pass class UnknownDomainError(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value) class SessionStopped(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value) def getTraceback(): import utils return utils.getTraceback() def errprint(msg): """ Append to the :data:`debug log` """ from utils import cstr debug_log.append(cstr(msg or '')) def msgprint(msg, small=0, raise_exception=0, as_table=False): """ Append to the :data:`message_log` """ from utils import cstr if as_table and type(msg) in (list, tuple): msg = '
%s | ' % c for c in r])+'