Opened 14 years ago

Closed 2 hours ago

#18603 closed Cleanup/optimization (needsinfo)

Adding support for PEP 302 importers

Reported by: bhuztez Owned by:
Component: Core (Other) Version:
Severity: Normal Keywords:
Cc: cberner, Harsh007 Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django makes assumptions about the filesystem layout of python packages here and there, and will silently skip any app which does not meet Django's assumptions without raise up any warnings.

Adding support for PEP 302 importers can solve all these problems, including #582 #596 #8238 #8280 #12206 #13587 #16718 #17331. And I found that there are three different kinds of problems.

  1. find submodules before importing the package: finding management commands
  2. find submodules after importing the package: finding template tags(already solved by #13334) and listing available database backends
  3. find resource files after importing the package: template files, static files, fixtures and translation files

I have been working on solve these problems in the past few months, code is now available on Github: https://github.com/bhuztez/django/compare/master...pep-302

There are still a few problems.

management command
since we have to find management commands before importing any app packages, we still need to make assumptions, see https://code.djangoproject.com/ticket/14087#comment:13 . I think we have to make a better assumption on loader.get_filename. And how to find management commands in packages imported by sys.meta_path?
static files finder
I changed static files finder API. now Finder.find returns [(storage, path)] instead of [path].
app package resource file regression tests
templates, fixtures, translation files and static files (except collect_static) relies on same api to find resource files. Should I just add tests for the API, or I have to add almost same tests for templates, fixtures, translation files and static files?
template loader
I changed template loader API. I think the template_dirs parameter is confusing here in loader(template_name, template_dirs=None). if I set the template_dirs parameter, django.template.loaders.app_directories.Loader works just like django.template.loaders.filesystem.Loader, and django.template.loaders.eggs.Loader does not respect my parameter.
fixture path
how to humanize(fixture_storage)?

Any ideas?

Change History (7)

comment:1 by Aymeric Augustin, 14 years ago

Triage Stage: UnreviewedAccepted

comment:2 by cberner, 14 years ago

Cc: cberner added

Hey bhuztez,

I started work on part of this (the management command issue) because we've run into it. My patch is here. Let me know if I can be of assistance with other parts of this issue.

comment:3 by Aymeric Augustin, 13 years ago

Component: UncategorizedCore (Other)

comment:4 by Tim Graham, 12 years ago

Patch needs improvement: set

comment:5 by Harsh007, 22 hours ago

Cc: Harsh007 added
Owner: changed from nobody to Harsh007
Status: newassigned

comment:6 by Harsh007, 21 hours ago

Owner: Harsh007 removed
Status: assignednew

comment:7 by Jacob Walls, 2 hours ago

Has patch: unset
Patch needs improvement: unset
Resolution: needsinfo
Status: newclosed

I don't think this is actionable today. My best effort to identify any remaining issues found nothing, see ticket:14087#comment:31.

Note: See TracTickets for help on using tickets.
Back to Top