A Python content management system designed for kirsle.net featuring a blog, comments and photo albums. https://rophako.kirsle.net/
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

30 строки
1.1 KiB

  1. #!/usr/bin/env python
  2. """Dynamic CMS plugin loader."""
  3. import os
  4. from importlib import import_module
  5. from rophako.app import app, BLUEPRINT_PATHS
  6. def load_plugin(name, as_blueprint=True, template_path=None):
  7. """Load a Rophako CMS plugin.
  8. * `name` is a Python module name, i.e. `rophako.modules.blog`
  9. * `as_blueprint` is True if the module exports a blueprint object called
  10. `mod` that can be attached to the Flask app. Set this value to False if
  11. you simply need to include a Python module that isn't a blueprint.
  12. * `template_path` is a filesystem path where the blueprint's templates
  13. can be found. If not provided, the path is automatically determined
  14. based on the module name, which is suitable for the built-in plugins."""
  15. module = import_module(name)
  16. if as_blueprint:
  17. mod = getattr(module, "mod")
  18. app.register_blueprint(mod)
  19. # Get the template path to add to the BLUEPRINT_PATHS.
  20. if template_path is None:
  21. module_path = name.replace(".", "/")
  22. template_path = os.path.join(module_path, "templates")
  23. BLUEPRINT_PATHS.append(template_path)