當前位置: 首頁>>代碼示例>>Python>>正文


Python DocList.append方法代碼示例

本文整理匯總了Python中webnotes.model.doclist.DocList.append方法的典型用法代碼示例。如果您正苦於以下問題:Python DocList.append方法的具體用法?Python DocList.append怎麽用?Python DocList.append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在webnotes.model.doclist.DocList的用法示例。


在下文中一共展示了DocList.append方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getchildren

# 需要導入模塊: from webnotes.model.doclist import DocList [as 別名]
# 或者: from webnotes.model.doclist.DocList import append [as 別名]
def getchildren(name, childtype, field='', parenttype='', from_doctype=0, prefix='tab'):
	import webnotes
	from webnotes.model.doclist import DocList
	
	condition = ""
	values = []
	
	if field: 
		condition += ' and parentfield=%s '
		values.append(field)
	if parenttype:
		condition += ' and parenttype=%s '
		values.append(parenttype)

	dataset = webnotes.conn.sql("""select * from `%s%s` where parent=%s %s order by idx""" \
		% (prefix, childtype, "%s", condition), tuple([name]+values))
	desc = webnotes.conn.get_description()

	l = DocList()
	
	for i in dataset:
		d = Document()
		d.doctype = childtype
		d._load_values(i, desc)
		l.append(d)
	
	return l
開發者ID:appost,項目名稱:wnframework,代碼行數:29,代碼來源:doc.py

示例2: sort_fields

# 需要導入模塊: from webnotes.model.doclist import DocList [as 別名]
# 或者: from webnotes.model.doclist.DocList import append [as 別名]
def sort_fields(doclist):
	"""sort on basis of previous_field"""
	from webnotes.model.doclist import DocList
	newlist = DocList([])
	pending = filter(lambda d: d.doctype=='DocField', doclist)
	
	maxloops = 20
	while (pending and maxloops>0):
		maxloops -= 1
		for d in pending[:]:
			if d.previous_field:
				# field already added
				for n in newlist:
					if n.fieldname==d.previous_field:
						newlist.insert(newlist.index(n)+1, d)
						pending.remove(d)
						break
			else:
				newlist.append(d)
				pending.remove(d)

	# recurring at end	
	if pending:
		newlist += pending

	# renum
	idx = 1
	for d in newlist:
		d.idx = idx
		idx += 1

	doclist.get({"doctype":["!=", "DocField"]}).extend(newlist)
開發者ID:ricardomomm,項目名稱:wnframework,代碼行數:34,代碼來源:doctype.py

示例3: sort_fields

# 需要導入模塊: from webnotes.model.doclist import DocList [as 別名]
# 或者: from webnotes.model.doclist.DocList import append [as 別名]
def sort_fields(doclist):
	"""sort on basis of previous_field"""

	from webnotes.model.doclist import DocList
	newlist = DocList([])
	pending = doclist.get({"doctype":"DocField"})

	if doclist[0].get("_idx"):
		for fieldname in json.loads(doclist[0].get("_idx")):
			d = doclist.get({"fieldname": fieldname})
			if d:
				newlist.append(d[0])
				pending.remove(d[0])
	else:
		maxloops = 20
		while (pending and maxloops>0):
			maxloops -= 1
			for d in pending[:]:
				if d.previous_field:
					# field already added
					for n in newlist:
						if n.fieldname==d.previous_field:
							newlist.insert(newlist.index(n)+1, d)
							pending.remove(d)
							break
				else:
					newlist.append(d)
					pending.remove(d)

	# recurring at end	
	if pending:
		newlist += pending

	# renum
	idx = 1
	for d in newlist:
		d.idx = idx
		idx += 1

	doclist.get({"doctype":["!=", "DocField"]}).extend(newlist)
開發者ID:bindscha,項目名稱:wnframework_old,代碼行數:42,代碼來源:doctype.py

示例4: getchildren

# 需要導入模塊: from webnotes.model.doclist import DocList [as 別名]
# 或者: from webnotes.model.doclist.DocList import append [as 別名]
def getchildren(name, childtype, field='', parenttype='', from_doctype=0, prefix='tab'):
	import webnotes
	from webnotes.model.doclist import DocList
	
	tmp = ''
	
	if field: 
		tmp = ' and parentfield="%s" ' % field
	if parenttype:
		tmp = ' and parenttype="%s" ' % parenttype

	dataset = webnotes.conn.sql("select * from `%s%s` where parent='%s' %s order by idx" \
		% (prefix, childtype, name, tmp))
	desc = webnotes.conn.get_description()

	l = DocList()
	
	for i in dataset:
		d = Document()
		d.doctype = childtype
		d._load_values(i, desc)
		l.append(d)
	
	return l
開發者ID:gowrav-vishwakarma,項目名稱:wnframework,代碼行數:26,代碼來源:doc.py


注:本文中的webnotes.model.doclist.DocList.append方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。