Example #1
0
def import_file(module, doctype, docname, path=None):
	"imports a given file into the database"
	
	if not path:
		from webnotes.modules import get_module_path
		path = get_module_path(module)
	
	doclist = get_doclist(path, doctype, docname)
	
	if doclist:
		from webnotes.utils.transfer import set_doc
		set_doc(doclist, 1, 1, 1)
Example #2
0
 def sync_doc(self, dt, dn):
         import webnotes
         from webnotes.utils import transfer
         
         webnotes.conn = self.master_conn
         import webnotes.model.doc
         print dt+' : '+dn
         # get from master
         doclist = webnotes.model.doc.get(dt, dn, from_get_obj = 1)
         # put
         webnotes.conn = self.conn
         print transfer.set_doc([d.fields for d in doclist], ovr = 1)
Example #3
0
    def sync(self, force=1):
        """
			import the doclist if new
		"""
        from webnotes.model.utils import peval_doclist
        doclist = peval_doclist(self.read())
        if doclist:
            from webnotes.utils.transfer import set_doc
            set_doc(doclist, 1, 1, 1)

            # since there is a new timestamp on the file, update timestamp in
            # the record
            webnotes.conn.sql("update `tab%s` set modified=now() where name=%s" \
             % (doclist[0]['doctype'], '%s'), doclist[0]['name'])
Example #4
0
	def sync(self, force=1):
		"""
			import the doclist if new
		"""
		from webnotes.model.utils import peval_doclist
		doclist = peval_doclist(self.read())
		if doclist:					
			from webnotes.utils.transfer import set_doc
			set_doc(doclist, 1, 1, 1)

			# since there is a new timestamp on the file, update timestamp in
			# the record
			webnotes.conn.sql("update `tab%s` set modified=now() where name=%s" \
				% (doclist[0]['doctype'], '%s'), doclist[0]['name'])
Example #5
0
def reload_single_doc(module, dt, dn):
	"""Sync a file from txt"""
	import os
	dt, dn = scrub_dt_dn(dt, dn)

	path = os.path.join(get_module_path(module), 
		os.path.join(dt, dn, dn + '.txt'))
		
	if os.path.exists(path):
		from webnotes.model.utils import peval_doclist
		
		with open(path, 'r') as f:
			doclist = peval_doclist(f.read())
			
		if doclist:					
			from webnotes.utils.transfer import set_doc
			set_doc(doclist, 1, 1, 1)

			# since there is a new timestamp on the file, update timestamp in
			webnotes.conn.sql("update `tab%s` set modified=now() where name=%s" \
				% (doclist[0]['doctype'], '%s'), doclist[0]['name'])		
	else:
		raise Exception, '%s missing' % path
Example #6
0
def accept_module(super_doclist):
	import webnotes
	import webnotes.utils
	from webnotes.utils import transfer
	msg, i = [], 0
	
	for dl in super_doclist:
		if dl[0]['doctype']!='Control Panel':
			msg.append(transfer.set_doc(dl, 1, 1, 1))
		
		if dl[0]['doctype']=='Module Def':
			update_module_timestamp(dl[0]['name'])

	if not webnotes.conn.in_transaction:
		webnotes.conn.sql("START TRANSACTION")
	
	# clear cache
	webnotes.conn.sql("DELETE from __DocTypeCache")
	webnotes.conn.sql("COMMIT")
	
	return msg
Example #7
0
def accept_module(super_doclist):
	import webnotes
	import webnotes.utils
	from webnotes.utils import transfer
	msg, i = [], 0
	
	for dl in super_doclist:
		msg.append(transfer.set_doc(dl, 1, 1, 1))
		
		if dl[0]['doctype']=='Module Def':
			update_module_timestamp(dl[0]['name'])

	if not webnotes.conn.in_transaction:
		webnotes.conn.sql("START TRANSACTION")

	# clear over-written records / deleted child records
	webnotes.utils.clear_recycle_bin()
	
	# clear cache
	webnotes.conn.sql("DELETE from __DocTypeCache")
	webnotes.conn.sql("COMMIT")
	
	return msg