webnotes Package

webnotes Package

exception webnotes.ValidationError[source]

Bases: exceptions.Exception

webnotes.add_cookies

Dictionary of additional cookies appended by custom code

webnotes.conn

The database connection webnotes.db.Database setup by auth

webnotes.create_folder(path)[source]

Wrapper function for os.makedirs (does not throw exception if directory exists)

webnotes.debug_log

List of exceptions to be shown in the Error Console

webnotes.errprint(msg)[source]

Append to the debug log

webnotes.form

The cgi.FieldStorage() object (Dictionary representing the formdata from the URL)

webnotes.getTraceback()[source]
webnotes.get_env_vars(env_var)[source]
webnotes.get_files_path()[source]
webnotes.get_index_path()[source]
webnotes.is_apache_user()[source]
webnotes.is_testing

Flag to identify if system is in Testing Mode

webnotes.message_log

List of messages to be shown to the user in a popup box at the end of the request

webnotes.msgprint(msg, small=0, raise_exception=0)[source]

Append to the message_log

webnotes.response

The JSON response object. Default is:

{'message':'', 'exc':''}
webnotes.session

Global session dictionary.

  • session[‘user’] - Current user
  • session[‘data’] - Returns a dictionary of the session cache
webnotes.set_as_account_master()[source]
webnotes.set_as_admin(db_name=None, ac_name=None)[source]
webnotes.set_as_admin_session()[source]
webnotes.set_as_administrator()[source]
webnotes.setup_logging()[source]
webnotes.version

“v170”

auth Module

class webnotes.auth.CookieManager[source]
get_incoming_cookies()[source]
set_cookies()[source]
set_remember_me()[source]
class webnotes.auth.HTTPRequest[source]
get_ac_name()[source]
set_db(ac_name=None)[source]
setup_profile()[source]
class webnotes.auth.LoginManager[source]
authenticate(user=None, pwd=None)[source]
call_on_logout_event()[source]
load_control_panel()[source]
login_as_guest()[source]
logout(arg='')[source]
post_login()[source]
run_trigger(method='on_login')[source]
validate_ip_address()[source]
class webnotes.auth.Session(user=None)[source]
add_status_column()[source]
check_expired()[source]
get_ipinfo()[source]
insert_session_record()[source]
load()[source]
resume()[source]
start()[source]
update()[source]

db Module

class webnotes.db.Database(host='', user='', password='', ac_name='', use_default=0)[source]

Open a database connection with the given parmeters, if use_default is True, use the login details from defs.py. This is called by the request handler and is accessible using the conn global variable. the sql method is also global to run queries

add_multi_tenant_condition(query)[source]
begin()[source]
check_transaction_status(query)[source]

Update in_transaction and check if “START TRANSACTION” is not called twice

close()[source]

Close my connection

commit()[source]
connect()[source]

Connect to a database

convert_to_lists(res, formatted=0)[source]

Convert the given result set to a list of lists (with cleaned up dates and decimals)

convert_to_simple_type(v, formatted=0)[source]
exists(dt, dn)[source]

Returns true if the record exists

fetch_as_dict(formatted=0)[source]

Internal - get results as dictionary

field_exists(dt, fn)[source]

Returns True if fn exists in DocType dt

get_db_login(ac_name)[source]
get_description()[source]

Get metadata of the last query

get_global(key, user='__global')[source]
get_testing_tables()[source]

Get list of all tables for which tab is to be replaced by test before a query is executed

get_value(doctype, docname, fieldname)[source]

Get a single / multiple value from a record.

For Single DocType, let docname be = None

replace_tab_by_test(query)[source]

Relace all tab + doctype to test + doctype

rollback()[source]
set(doc, field, val)[source]
set_global(key, val, user='__global')[source]
set_value(dt, dn, field, val)[source]
sql(query, values=(), as_dict=0, as_list=0, formatted=0, ignore_no_table=1, debug=0)[source]
  • 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
use(db_name)[source]

USE db_name

validate_query(q)[source]

defs Module

defs_template Module

handler Module

webnotes.handler.backupdb(form_dict, session)[source]
webnotes.handler.cleanup_docs()[source]
webnotes.handler.compressBuf(buf)[source]
webnotes.handler.dt_map()[source]
webnotes.handler.get_file()[source]
webnotes.handler.get_graph()[source]
webnotes.handler.get_template()[source]
webnotes.handler.import_csv()[source]
webnotes.handler.load_month_events()[source]
webnotes.handler.logout()[source]
webnotes.handler.reset_password()[source]
webnotes.handler.resume_session()[source]
webnotes.handler.runserverobj(arg=None)[source]
webnotes.handler.startup()[source]
webnotes.handler.upload_many()[source]
webnotes.handler.uploadfile()[source]
webnotes.handler.validate_cmd(cmd)[source]

profile Module

class webnotes.profile.Profile(name='')[source]

A profile object is created at the beginning of every request with details of the use. The global profile object is webnotes.user

get_allow_list(key)[source]

Internal - get list of DocType where key is allowed. Key is either ‘read’, ‘write’ or ‘create’

get_create_list()[source]

Get list of DocTypes the user can create. Will filter DocTypes tagged with ‘not_in_create’ and table

get_defaults()[source]

Get the user’s default values based on user and role profile

get_hide_tips()[source]
get_home_page()[source]

Get the name of the user’s home page from the Control Panel

get_random_password()[source]

Generate a random password

get_read_list()[source]

Get list of DocTypes the user can read

get_report_list()[source]
get_roles()[source]

get list of roles

get_write_list()[source]

Get list of DocTypes the user can write

load_from_session(d)[source]

Setup the user profile from the dictionary saved in the session (generated by load_profile)

load_profile()[source]

Return a dictionary of user properites to be stored in the session

reset_password()[source]

Reset the user’s password and send an email

send_email(subj, mess, email)[source]
update_recent(dt, dn)[source]

Update the user’s Recent list with the given dt and dn

webnotes.profile.get_user_img()[source]

session_cache Module

webnotes.session_cache.build()[source]
webnotes.session_cache.clear()[source]
webnotes.session_cache.clear_cache(user='')[source]
webnotes.session_cache.dump(sd, country)[source]
webnotes.session_cache.get()[source]
webnotes.session_cache.get_letter_heads()[source]
webnotes.session_cache.load(country)[source]
webnotes.session_cache.load_startup(cp)[source]
webnotes.session_cache.make_cache_table()[source]

tests Module

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

webnotes.tests.get_tests()[source]

Returns list of test modules identified by “tests.py”

webnotes.tests.setup()[source]

Sets up connection and session

Table Of Contents

Previous topic

page Package

Next topic

install_lib Package

This Page