You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
598 B

  1. import webnotes
  2. @webnotes.whitelist()
  3. def get():
  4. """load print format by `name`"""
  5. import re
  6. html = get_html(webnotes.form.getvalue('name'))
  7. p = re.compile('\$import\( (?P<name> [^)]*) \)', re.VERBOSE)
  8. out_html = ''
  9. if html:
  10. out_html = p.sub(substitute, html)
  11. webnotes.response['message'] = out_html
  12. def substitute(match):
  13. """return matched printformat by html"""
  14. name = match.group('name')
  15. return get_html(name)
  16. def get_html(name):
  17. """load html from db"""
  18. html = webnotes.conn.sql('select html from `tabPrint Format` where name="%s"' % name)
  19. return html and html[0][0] or ''