Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

design_decisions.rst 1.4KB

123456789101112131415161718192021222324252627282930313233343536
  1. ================
  2. Design decisions
  3. ================
  4. Oscar's is designed to be open to customisation wherever possible. There are two
  5. main ways in which this is acheived.
  6. Dynamic importing of classes
  7. ----------------------------
  8. Within oscar itself, classes are imported using a special ``import_module`` function
  9. which determines which app to load the specified classes from. Sample usage is::
  10. import_module('product.models', ['Item', 'ItemClass'], locals())
  11. This will load the ``Item`` and ``ItemClass` classes into the local namespace. It is
  12. a replacement for the usual::
  13. from oscar.product.models import Item, ItemClass
  14. The ``import_module`` looks through your ``INSTALLED_APPS`` for a matching module to
  15. the one specified and will load the classes from there. If the matching module is
  16. not from oscar's core, then it will also fall back to the equivalent module if the
  17. class cannot be found.
  18. This structure enables a project to create a local ``product.models`` module and
  19. subclass and extend the core models from ``oscar.app.product.models``. When Oscar
  20. tries to load the ``Item`` class, it will load the one from your local project.
  21. Class-based views
  22. -----------------
  23. All views within oscar's core are class-based, which allows the above dynamic class
  24. loading to be used within ``urls.py`` modules, so that core views can be subclassed
  25. within projects to extend and customised them.