• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python webnotes._dict函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webnotes._dict函数的典型用法代码示例。如果您正苦于以下问题:Python _dict函数的具体用法?Python _dict怎么用?Python _dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了_dict函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: update_event

def update_event(args, field_map):
	args = webnotes._dict(json.loads(args))
	field_map = webnotes._dict(json.loads(field_map))
	w = webnotes.bean(args.doctype, args.name)
	w.doc.fields[field_map.start] = args[field_map.start]
	w.doc.fields[field_map.end] = args[field_map.end]
	w.save()
开发者ID:Halfnhav,项目名称:wnframework,代码行数:7,代码来源:calendar.py


示例2: get_last_purchase_details

def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
	"""returns last purchase details in stock uom"""
	# get last purchase order item details
	last_purchase_order = webnotes.conn.sql("""\
		select po.name, po.transaction_date, po.conversion_rate,
			po_item.conversion_factor, po_item.purchase_ref_rate, 
			po_item.discount_rate, po_item.purchase_rate
		from `tabPurchase Order` po, `tabPurchase Order Item` po_item
		where po.docstatus = 1 and po_item.item_code = %s and po.name != %s and 
			po.name = po_item.parent
		order by po.transaction_date desc, po.name desc
		limit 1""", (item_code, cstr(doc_name)), as_dict=1)

	# get last purchase receipt item details		
	last_purchase_receipt = webnotes.conn.sql("""\
		select pr.name, pr.posting_date, pr.posting_time, pr.conversion_rate,
			pr_item.conversion_factor, pr_item.purchase_ref_rate, pr_item.discount_rate,
			pr_item.purchase_rate
		from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
		where pr.docstatus = 1 and pr_item.item_code = %s and pr.name != %s and
			pr.name = pr_item.parent
		order by pr.posting_date desc, pr.posting_time desc, pr.name desc
		limit 1""", (item_code, cstr(doc_name)), as_dict=1)

	purchase_order_date = getdate(last_purchase_order and last_purchase_order[0].transaction_date \
		or "1900-01-01")
	purchase_receipt_date = getdate(last_purchase_receipt and \
		last_purchase_receipt[0].posting_date or "1900-01-01")

	if (purchase_order_date > purchase_receipt_date) or \
			(last_purchase_order and not last_purchase_receipt):
		# use purchase order
		last_purchase = last_purchase_order[0]
		purchase_date = purchase_order_date
		
	elif (purchase_receipt_date > purchase_order_date) or \
			(last_purchase_receipt and not last_purchase_order):
		# use purchase receipt
		last_purchase = last_purchase_receipt[0]
		purchase_date = purchase_receipt_date
		
	else:
		return webnotes._dict()
	
	conversion_factor = flt(last_purchase.conversion_factor)
	out = webnotes._dict({
		"purchase_ref_rate": flt(last_purchase.purchase_ref_rate) / conversion_factor,
		"purchase_rate": flt(last_purchase.purchase_rate) / conversion_factor,
		"discount_rate": flt(last_purchase.discount_rate),
		"purchase_date": purchase_date
	})

	conversion_rate = flt(conversion_rate) or 1.0
	out.update({
		"import_ref_rate": out.purchase_ref_rate / conversion_rate,
		"import_rate": out.purchase_rate / conversion_rate,
		"rate": out.purchase_rate
	})
	
	return out
开发者ID:Anirudh887,项目名称:erpnext,代码行数:60,代码来源:utils.py


示例3: validate_currency

def validate_currency(args, item, meta=None):
	from webnotes.model.meta import get_field_precision
	if not meta:
		meta = webnotes.get_doctype(args.doctype)
		
	# validate conversion rate
	if meta.get_field("currency"):
		validate_conversion_rate(args.currency, args.conversion_rate, 
			meta.get_label("conversion_rate"), args.company)
		
		# round it
		args.conversion_rate = flt(args.conversion_rate, 
			get_field_precision(meta.get_field("conversion_rate"), 
				webnotes._dict({"fields": args})))
	
	# validate price list conversion rate
	if meta.get_field("price_list_currency") and (args.selling_price_list or args.buying_price_list) \
		and args.price_list_currency:
		validate_conversion_rate(args.price_list_currency, args.plc_conversion_rate, 
			meta.get_label("plc_conversion_rate"), args.company)
		
		# round it
		args.plc_conversion_rate = flt(args.plc_conversion_rate, 
			get_field_precision(meta.get_field("plc_conversion_rate"), 
				webnotes._dict({"fields": args})))
开发者ID:rajatkapoor,项目名称:erpnext,代码行数:25,代码来源:transaction_base.py


示例4: get_values_from_single

	def get_values_from_single(self, fields, filters, doctype, as_dict=False, debug=False):
		if fields=="*" or isinstance(filters, dict):
			r = self.sql("""select field, value from tabSingles where doctype=%s""", doctype)
			
			# check if single doc matches with filters
			values = webnotes._dict(r)
			if isinstance(filters, dict):
				for key, value in filters.items():
					if values.get(key) != value:
						return []
			
			if as_dict:
				return values and [values] or []
				
			if isinstance(fields, list):
				return [map(lambda d: values.get(d), fields)]
					
		else:
			r = self.sql("""select field, value 
				from tabSingles where field in (%s) and doctype=%s""" \
					% (', '.join(['%s'] * len(fields)), '%s'), 
					tuple(fields) + (doctype,), as_dict=False, debug=debug)

			if as_dict:
				return r and [webnotes._dict(r)] or []
			else:
				return r and [[i[1] for i in r]] or []
开发者ID:saurabh6790,项目名称:pow-lib,代码行数:27,代码来源:db.py


示例5: get_bootinfo

def get_bootinfo():
	"""build and return boot info"""
	bootinfo = webnotes._dict()
	hooks = webnotes.get_hooks()
	doclist = []

	# profile
	get_profile(bootinfo)
	
	# control panel
	cp = webnotes.model.doc.getsingle('Control Panel')
		
	# system info
	bootinfo['control_panel'] = webnotes._dict(cp.copy())
	bootinfo['sysdefaults'] = webnotes.defaults.get_defaults()
	bootinfo['server_date'] = webnotes.utils.nowdate()
	bootinfo["send_print_in_body_and_attachment"] = webnotes.conn.get_value("Email Settings", 
		None, "send_print_in_body_and_attachment")

	if webnotes.session['user'] != 'Guest':
		bootinfo['user_info'] = get_fullnames()
		bootinfo['sid'] = webnotes.session['sid'];
		
	# home page
	bootinfo.modules = {}
	for app in webnotes.get_installed_apps():
		try:
			bootinfo.modules.update(webnotes.get_attr(app + ".config.desktop.data") or {})
		except ImportError, e:
			pass
开发者ID:bindscha,项目名称:wnframework_old,代码行数:30,代码来源:boot.py


示例6: uncommonify_doclist

def uncommonify_doclist(dl):
	"""
		Expands an commonified doclist
	"""
	# first one has common values
	common_values = dl[0]
	common_dict = webnotes._dict()
	final = []
	idx_dict = {}

	for d in dl[1:]:
		if 'name' in d and d['name']=='__common__':
			# common for a doctype - 
			del d['name']
			common_dict[d['doctype']] = d
		else:
			dt = d['doctype']
			if not dt in idx_dict: idx_dict[dt] = 1;
			d1 = webnotes._dict(common_values.copy())

			# update from common and global
			d1.update(common_dict[dt])
			d1.update(d)

			# idx by sequence
			d1['idx'] = idx_dict[dt]
			
			# increment idx
			idx_dict[dt] += 1

			final.append(d1)

	return final
开发者ID:akshayagarwal,项目名称:wnframework,代码行数:33,代码来源:utils.py


示例7: build_field_columns

	def build_field_columns(dt):
		doctype_dl = webnotes.model.doctype.get(dt)

		tablecolumns = filter(None, 
			[doctype_dl.get_field(f[0]) for f in webnotes.conn.sql('desc `tab%s`' % dt)])

		tablecolumns.sort(lambda a, b: a.idx - b.idx)

		if dt==doctype:
			column_start_end[dt] = webnotes._dict({"start": 0})
		else:
			column_start_end[dt] = webnotes._dict({"start": len(columns)})
			
			append_field_column(webnotes._dict({
				"fieldname": "name",
				"label": "ID",
				"fieldtype": "Data",
				"reqd": 1,
				"idx": 0,
				"info": "Leave blank for new records"
			}), True)
			
		for docfield in tablecolumns:
			append_field_column(docfield, True)

		# all non mandatory fields
		for docfield in tablecolumns:
			append_field_column(docfield, False)

		# append DocType name
		tablerow[column_start_end[dt].start + 1] = dt
		if dt!=doctype:
			tablerow[column_start_end[dt].start + 2] = doctype_parentfield[dt]

		column_start_end[dt].end = len(columns) + 1
开发者ID:bindscha,项目名称:wnframework_old,代码行数:35,代码来源:data_import_tool.py


示例8: execute

def execute(filters=None):
    if not filters:
        filters = {}

    employee_filters = filters.get("company") and [["Employee", "company", "=", filters.get("company")]] or None
    employees = runreport(doctype="Employee", fields=["name", "employee_name", "department"], filters=employee_filters)
    leave_types = webnotes.conn.sql_list("select name from `tabLeave Type`")

    if filters.get("fiscal_year"):
        fiscal_years = [filters["fiscal_year"]]
    else:
        fiscal_years = webnotes.conn.sql_list("select name from `tabFiscal Year` order by name desc")

    employee_in = '", "'.join([e.name for e in employees])

    allocations = webnotes.conn.sql(
        """select employee, fiscal_year, leave_type, total_leaves_allocated
	 	from `tabLeave Allocation` 
		where docstatus=1 and employee in ("%s")"""
        % employee_in,
        as_dict=True,
    )
    applications = webnotes.conn.sql(
        """select employee, fiscal_year, leave_type, SUM(total_leave_days) as leaves
			from `tabLeave Application` 
			where status="Approved" and docstatus = 1 and employee in ("%s")
			group by employee, fiscal_year, leave_type"""
        % employee_in,
        as_dict=True,
    )

    columns = ["Fiscal Year", "Employee:Link/Employee:150", "Employee Name::200", "Department::150"]

    for leave_type in leave_types:
        columns.append(leave_type + " Allocated:Float")
        columns.append(leave_type + " Taken:Float")
        columns.append(leave_type + " Balance:Float")

    data = {}
    for d in allocations:
        data.setdefault(
            (d.fiscal_year, d.employee, d.leave_type), webnotes._dict()
        ).allocation = d.total_leaves_allocated

    for d in applications:
        data.setdefault((d.fiscal_year, d.employee, d.leave_type), webnotes._dict()).leaves = d.leaves

    result = []
    for fiscal_year in fiscal_years:
        for employee in employees:
            row = [fiscal_year, employee.name, employee.employee_name, employee.department]
            result.append(row)
            for leave_type in leave_types:
                tmp = data.get((fiscal_year, employee.name, leave_type), webnotes._dict())
                row.append(tmp.allocation or 0)
                row.append(tmp.leaves or 0)
                row.append((tmp.allocation or 0) - (tmp.leaves or 0))

    return columns, result
开发者ID:rafuru,项目名称:erpnext,代码行数:59,代码来源:employee_leave_balance.py


示例9: build_page

def build_page(page_name):
	if not webnotes.conn:
		webnotes.connect()

	sitemap = get_website_sitemap()
	page_options = sitemap.get(page_name)
	
	if not page_options:
		if page_name=="index":
			# page not found, try home page
			home_page = get_home_page()
			page_options = sitemap.get(home_page)
			if not page_options:
				raise PageNotFoundError
			page_options["page_name"] = home_page
		else:
			raise PageNotFoundError
	else:
		page_options["page_name"] = page_name
	
	basepath = webnotes.utils.get_base_path()
	module = None
	no_cache = False
	
	if page_options.get("controller"):
		module = webnotes.get_module(page_options["controller"])
		no_cache = getattr(module, "no_cache", False)

	# if generator, then load bean, pass arguments
	if page_options.get("is_generator"):
		if not module:
			raise Exception("Generator controller not defined")
		
		name = webnotes.conn.get_value(module.doctype, {
			page_options.get("page_name_field", "page_name"): page_options["page_name"]})
		obj = webnotes.get_obj(module.doctype, name, with_children=True)

		if hasattr(obj, 'get_context'):
			obj.get_context()

		context = webnotes._dict(obj.doc.fields)
		context["obj"] = obj
	else:
		# page
		context = webnotes._dict({ 'name': page_name })
		if module and hasattr(module, "get_context"):
			context.update(module.get_context())
	
	context.update(get_website_settings())

	jenv = webnotes.get_jenv()
	context["base_template"] = jenv.get_template(webnotes.get_config().get("base_template"))
	
	template_name = page_options['template']	
	html = jenv.get_template(template_name).render(context)
	
	if not no_cache:
		webnotes.cache().set_value("page:" + page_name, html)
	return html
开发者ID:ricardomomm,项目名称:wnframework,代码行数:59,代码来源:webutils.py


示例10: get_data

def get_data(rows, company_abbr):
	start_row = 0
	data = []
	start_row_idx = 0
	for i in xrange(len(rows)):
		r = rows[i]
		if r[0]:
			if start_row and i >= start_row:
				if not start_row_idx: start_row_idx = i
				d, acc_dict = webnotes._dict(), webnotes._dict()
				for cidx in xrange(len(columns)):
					d[columns[cidx]] = r[cidx]
					
				if accounts:
					total_debit = total_credit = 0
					for acc_idx in xrange(len(accounts)):
						col_idx = len(columns) + acc_idx
						if flt(r[col_idx]) != 0:
							if not acc_dict.get(accounts[acc_idx]):
								acc_dict[accounts[acc_idx]] = 0
							acc_dict[accounts[acc_idx]] += flt(r[col_idx])
						if flt(r[col_idx]) > 0:
							total_debit += flt(r[col_idx])
						else:
							total_credit += abs(flt(r[col_idx]))
							
					d['total_debit'] = total_debit
					d['total_credit'] = total_credit
				
				data.append([d, acc_dict])
				

			if r[0]=="--------Data----------":
				start_row = i+2
				
				# check for empty columns
				empty_columns = [j+1 for j, c in enumerate(rows[i+1]) if not c]
				if empty_columns:
					raise Exception, """Column No(s). %s %s empty. \
						Please remove them and try again.""" % (comma_and(empty_columns),
						len(empty_columns)==1 and "is" or "are")

				columns = [c.replace(" ", "_").lower() for c in rows[i+1] 
					if not c.endswith(" - " + company_abbr)]
				accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)]

				if not accounts:
					webnotes.msgprint(_("""No Account found in csv file, 
						May be company abbreviation is not correct"""), raise_exception=1)

				if accounts and (len(columns) != rows[i+1].index(accounts[0])):
					webnotes.msgprint(_("""All account columns should be after \
						standard columns and on the right.
						If you entered it properly, next probable reason \
						could be wrong account name.
						Please rectify it in the file and try again."""), raise_exception=1)
				
	return data, start_row_idx
开发者ID:bindscha,项目名称:erpnext-fork,代码行数:58,代码来源:voucher_import_tool.py


示例11: get_item_list

	def get_item_list(self, obj, is_stopped=0):
		"""get item list"""
		il = []
		for d in getlist(obj.doclist, obj.fname):
			reserved_warehouse = ""
			reserved_qty_for_main_item = 0
			
			if obj.doc.doctype == "Sales Order":
				if (webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or 
					self.has_sales_bom(d.item_code)) and not d.reserved_warehouse:
						webnotes.throw(_("Please enter Reserved Warehouse for item ") + 
							d.item_code + _(" as it is stock Item or packing item"))
				reserved_warehouse = d.reserved_warehouse
				if flt(d.qty) > flt(d.delivered_qty):
					reserved_qty_for_main_item = flt(d.qty) - flt(d.delivered_qty)
				
			if obj.doc.doctype == "Delivery Note" and d.against_sales_order:
				# if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
				# But in this case reserved qty should only be reduced by 10 and not 12
				
				already_delivered_qty = self.get_already_delivered_qty(obj.doc.name, 
					d.against_sales_order, d.prevdoc_detail_docname)
				so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.prevdoc_detail_docname)
				
				if already_delivered_qty + d.qty > so_qty:
					reserved_qty_for_main_item = -(so_qty - already_delivered_qty)
				else:
					reserved_qty_for_main_item = -flt(d.qty)

			if self.has_sales_bom(d.item_code):
				for p in getlist(obj.doclist, 'packing_details'):
					if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
						# the packing details table's qty is already multiplied with parent's qty
						il.append(webnotes._dict({
							'warehouse': p.warehouse,
							'reserved_warehouse': reserved_warehouse,
							'item_code': p.item_code,
							'qty': flt(p.qty),
							'reserved_qty': (flt(p.qty)/flt(d.qty)) * reserved_qty_for_main_item,
							'uom': p.uom,
							'batch_no': cstr(p.batch_no).strip(),
							'serial_no': cstr(p.serial_no).strip(),
							'name': d.name
						}))
			else:
				il.append(webnotes._dict({
					'warehouse': d.warehouse,
					'reserved_warehouse': reserved_warehouse,
					'item_code': d.item_code,
					'qty': d.qty,
					'reserved_qty': reserved_qty_for_main_item,
					'uom': d.stock_uom,
					'batch_no': cstr(d.batch_no).strip(),
					'serial_no': cstr(d.serial_no).strip(),
					'name': d.name
				}))
		return il
开发者ID:mxmo-co,项目名称:erpnext,代码行数:57,代码来源:sales_common.py


示例12: get_transaction_context

def get_transaction_context(doctype, name):
	customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, 
		"customer")
	
	bean = webnotes.bean(doctype, name)
	if bean.doc.customer != customer:
		return { "bean": webnotes._dict({ "doc": webnotes._dict({"name": _("Not Allowed")}) }) }
	else:
		return { "bean": bean }
开发者ID:akaifi,项目名称:shopping-cart,代码行数:9,代码来源:utils.py


示例13: fmap

	def fmap(self):
		if not hasattr(self, "_fmap"):
			if self.doc.doctype in ["Lead", "Quotation", "Sales Order", "Sales Invoice",
					"Delivery Note"]:
				self._fmap = webnotes._dict(	{
					"exchange_rate": "conversion_rate",
					"taxes_and_charges": "other_charges",
					"taxes_and_charges_master": "charge",
					"taxes_and_charges_total": "other_charges_total",
					"net_total_print": "net_total_print",
					"grand_total_print": "grand_total_export",
					"grand_total_in_words": "grand_total_in_words",
					"grand_total_in_words_print": "grand_total_in_words_print",
					"rounded_total_print": "rounded_total_export",
					"rounded_total_in_words": "in_words",
					"rounded_total_in_words_print": "in_words_export",
					"print_ref_rate": "ref_rate",
					"discount": "adj_rate",
					"print_rate": "export_rate",
					"print_amount": "export_amount",
					"ref_rate": "base_ref_rate",
					"rate": "basic_rate",
					
					"plc_exchange_rate": "plc_conversion_rate",
					"tax_calculation": "other_charges_calculation",
					"cost_center": "cost_center_other_charges",
				})
			else:
				self._fmap = webnotes._dict({
					"exchange_rate": "conversion_rate",
					"taxes_and_charges": "purchase_tax_details",
					"taxes_and_charges_master": "purchase_other_charges",
					"taxes_and_charges_total": "total_tax",
					"net_total_print": "net_total_import",
					"grand_total_print": "grand_total_import",
					"grand_total_in_words": "in_words",
					"grand_total_in_words_print": "in_words_import",
					"rounded_total_print": "rounded_total_print",
					"rounded_total_in_words": "rounded_total_in_words",
					"rounded_total_in_words_print": "rounded_total_in_words_print",
					"print_ref_rate": "import_ref_rate",
					"discount": "discount_rate",
					"print_rate": "import_rate",
					"print_amount": "import_amount",
					"ref_rate": "purchase_ref_rate",
					"rate": "purchase_rate",
					
					"valuation_tax_amount": "item_tax_amount"
				})
				
				if self.doc.doctype == "Purchase Invoice":
					self._fmap.update({
						"rate": "rate"
					})
			
		return self._fmap or webnotes._dict()
开发者ID:AminfiBerlin,项目名称:erpnext,代码行数:56,代码来源:transaction_controller.py


示例14: get_item_sales_bom

def get_item_sales_bom():
	item_sales_bom = {}
	
	for d in webnotes.conn.sql("""select parenttype, parent, parent_item,
		item_code, warehouse, -1*qty as total_qty
		from `tabDelivery Note Packing Item` where docstatus=1""", as_dict=True):
		item_sales_bom.setdefault(d.parenttype, webnotes._dict()).setdefault(d.parent,
			webnotes._dict()).setdefault(d.parent_item, []).append(d)

	return item_sales_bom
开发者ID:PhamThoTam,项目名称:erpnext,代码行数:10,代码来源:gross_profit.py


示例15: __init__

	def __init__(self, user=None):
		self.user = user
		self.sid = webnotes.form_dict.get('sid') or webnotes.request.cookies.get('sid', 'Guest')
		self.data = webnotes._dict({'user':user,'data': webnotes._dict({})})
		self.time_diff = None

		if webnotes.form_dict.get('cmd')=='login':
			self.start()
			return
			
		self.load()
开发者ID:Tejal011089,项目名称:medsyn2_lib,代码行数:11,代码来源:sessions.py


示例16: __init__

    def __init__(self, user=None):
        self.user = user
        self.sid = webnotes.form_dict.get("sid") or webnotes.incoming_cookies.get("sid", "Guest")
        self.data = webnotes._dict({"user": user, "data": webnotes._dict({})})
        self.time_diff = None

        if webnotes.form_dict.get("cmd") == "login":
            self.start()
            return

        self.load()
开发者ID:rohitw1991,项目名称:adbwnf,代码行数:11,代码来源:sessions.py


示例17: initialize_gle_map

def initialize_gle_map(gl_entries):
	gle_map = webnotes._dict()
	for gle in gl_entries:
		gle_map.setdefault(gle.account, webnotes._dict({
			"opening": 0,
			"entries": [],
			"total_debit": 0,
			"total_credit": 0,
			"closing": 0
		}))
	return gle_map
开发者ID:abordin,项目名称:erpnext,代码行数:11,代码来源:general_ledger.py


示例18: get_bootinfo

def get_bootinfo():
	"""build and return boot info"""
	bootinfo = webnotes._dict()
	doclist = []

	# profile
	get_profile(bootinfo)
	
	# control panel
	cp = webnotes.model.doc.getsingle('Control Panel')

	
	# system info
	bootinfo['control_panel'] = webnotes._dict(cp.copy())
	bootinfo['sysdefaults'] = webnotes.defaults.get_defaults()
	bootinfo['server_date'] = webnotes.utils.nowdate()
	bootinfo["send_print_in_body_and_attachment"] = webnotes.conn.get_value("Email Settings", 
		None, "send_print_in_body_and_attachment")

	if webnotes.session['user'] != 'Guest':
		bootinfo['user_info'] = get_fullnames()
		bootinfo['sid'] = webnotes.session['sid'];
		
	# home page
	bootinfo.modules = webnotes.get_config().modules
	bootinfo.hidden_modules = webnotes.conn.get_global("hidden_modules")
	bootinfo.doctype_icons = dict(webnotes.conn.sql("""select name, icon from 
		tabDocType where ifnull(icon,'')!=''"""))
	bootinfo.doctype_icons.update(dict(webnotes.conn.sql("""select name, icon from 
		tabPage where ifnull(icon,'')!=''""")))
	
	add_home_page(bootinfo, doclist)
	add_allowed_pages(bootinfo)
	load_translations(bootinfo)
	load_conf_settings(bootinfo)

	# ipinfo
	if webnotes.session['data'].get('ipinfo'):
		bootinfo['ipinfo'] = webnotes.session['data']['ipinfo']
	
	# add docs
	bootinfo['docs'] = doclist
	
	# plugins
	try:
		import startup.boot
		startup.boot.boot_session(bootinfo)
	except ImportError:
		pass
	
	from webnotes.model.utils import compress
	bootinfo['docs'] = compress(bootinfo['docs'])
	
	return bootinfo
开发者ID:rohitw1991,项目名称:latestadbwnf,代码行数:54,代码来源:boot.py


示例19: get_bootinfo

def get_bootinfo():
    """build and return boot info"""
    bootinfo = webnotes._dict()
    doclist = []

    # profile
    get_profile(bootinfo)

    # control panel
    cp = webnotes.model.doc.getsingle("Control Panel")

    # system info
    bootinfo["control_panel"] = webnotes._dict(cp.copy())
    bootinfo["sysdefaults"] = webnotes.defaults.get_defaults()
    bootinfo["server_date"] = webnotes.utils.nowdate()
    bootinfo["send_print_in_body_and_attachment"] = webnotes.conn.get_value(
        "Email Settings", None, "send_print_in_body_and_attachment"
    )

    if webnotes.session["user"] != "Guest":
        bootinfo["user_info"] = get_fullnames()
        bootinfo["sid"] = webnotes.session["sid"]

        # home page
    bootinfo.modules = webnotes.get_config().modules
    bootinfo.hidden_modules = webnotes.conn.get_global("hidden_modules")
    add_home_page(bootinfo, doclist)
    add_allowed_pages(bootinfo)
    load_translations(bootinfo)
    load_country_and_currency(bootinfo, doclist)

    # ipinfo
    if webnotes.session["data"].get("ipinfo"):
        bootinfo["ipinfo"] = webnotes.session["data"]["ipinfo"]

        # add docs
    bootinfo["docs"] = doclist

    # plugins
    try:
        import startup.boot

        startup.boot.boot_session(bootinfo)
    except ImportError:
        pass

    from webnotes.model.utils import compress

    bootinfo["docs"] = compress(bootinfo["docs"])

    return bootinfo
开发者ID:rohitw1991,项目名称:adbwnf,代码行数:51,代码来源:boot.py


示例20: build_page

def build_page(page_name):
	if not webnotes.conn:
		webnotes.connect()

	sitemap_options = webnotes.doc("Website Sitemap", page_name).fields
	
	page_options = webnotes.doc("Website Sitemap Config", 
		sitemap_options.get("website_sitemap_config")).fields.update({
			"page_name":sitemap_options.page_name,
			"docname":sitemap_options.docname
		})
		
	if not page_options:
		raise PageNotFoundError
	else:
		page_options["page_name"] = page_name
	
	basepath = webnotes.utils.get_base_path()
	no_cache = page_options.get("no_cache")
	

	# if generator, then load bean, pass arguments
	if page_options.get("page_or_generator")=="Generator":
		doctype = page_options.get("ref_doctype")
		obj = webnotes.get_obj(doctype, page_options["docname"], with_children=True)

		if hasattr(obj, 'get_context'):
			obj.get_context()

		context = webnotes._dict(obj.doc.fields)
		context["obj"] = obj
	else:
		# page
		context = webnotes._dict({ 'name': page_name })
		if page_options.get("controller"):
			module = webnotes.get_module(page_options.get("controller"))
			if module and hasattr(module, "get_context"):
				context.update(module.get_context())
	
	context.update(get_website_settings())

	jenv = webnotes.get_jenv()
	context["base_template"] = jenv.get_template(webnotes.get_config().get("base_template"))
	
	template_name = page_options['template_path']	
	html = jenv.get_template(template_name).render(context)
	
	if not no_cache:
		webnotes.cache().set_value("page:" + page_name, html)
	return html
开发者ID:Halfnhav,项目名称:wnframework,代码行数:50,代码来源:webutils.py



注:本文中的webnotes._dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python webnotes.bean函数代码示例发布时间:2022-05-26
下一篇:
Python webnotes._函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap