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.
 
 
 
 
 
 

69 line
2.0 KiB

  1. :mod:`code` --- Code Execution Module
  2. =====================================
  3. .. module:: code
  4. :synopsis: Code Execution module
  5. This is where all the plug-in code is executed. The standard method for DocTypes is declaration of a
  6. standardized `DocType` class that has the methods of any DocType. When an object is instantiated using the
  7. `get_obj` method, it creates an instance of the `DocType` class of that particular DocType and sets the
  8. `doc` and `doclist` attributes that represent the fields (properties) of that record.
  9. methods in following modules are imported for backward compatibility
  10. * webnotes.*
  11. * webnotes.utils.*
  12. * webnotes.model.doc.*
  13. * webnotes.model.doclist.*
  14. Global Properties / Methods (generally) used in server side scripts
  15. -------------------------------------------------------------------
  16. .. data:: version
  17. "v170"
  18. .. data:: NEWLINE
  19. "\\n" - used in plug in scripts
  20. .. function:: set
  21. Same as `webnotes.conn.set`
  22. Sets a value
  23. .. function:: sql(query, values=(), as_dict = 0, as_list = 0, allow_testing = 1)
  24. Same as `webnotes.conn.sql`
  25. .. function:: get_value
  26. Sames as `webnotes.conn.get_value`
  27. .. function:: convert_to_lists
  28. Same as `webnotes.conn.convert_to_lists`
  29. Module Methods
  30. --------------
  31. .. function:: execute(code, doc=None, doclist=[])
  32. Execute the code, if doc is given, then return the instance of the `DocType` class created
  33. .. function:: get_server_obj(doc, doclist = [], basedoctype = '')
  34. Returns the instantiated `DocType` object. Will also manage caching & compiling
  35. .. function:: get_obj(dt = None, dn = None, doc=None, doclist=[], with_children = 0)
  36. Returns the instantiated `DocType` object. Here you can pass the DocType and name (ID) to get the object.
  37. If with_children is true, then all child records will be laoded and added in the doclist.
  38. .. function:: run_server_obj(server_obj, method_name, arg=None)
  39. Executes a method (`method_name`) from the given object (`server_obj`)