Opened 8 years ago

Closed 6 years ago

#15562 closed New feature (wontfix)

include_patterns in staticfiles finder

Reported by: German M. Bravo Owned by: nobody
Component: contrib.staticfiles Version: 1.3-rc
Severity: Normal Keywords:
Cc: German M. Bravo Triage Stage: Design decision needed
Has patch: no Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no


For completeness and also to be able to include only files like *.gif or the like, I've added include_patterns to the list() method in the staticfiles finders. I'm attaching a patch for that.

Attachments (2)

#15562-include_patterns.diff (4.4 KB) - added by German M. Bravo 8 years ago.
#15562-include_patterns-1.4.diff (5.0 KB) - added by German M. Bravo 7 years ago.
Patch updated for 1.4

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by German M. Bravo

comment:1 Changed 8 years ago by Jannis Leidel

The finder API is currently considered private API, so can you elaborate on the use of this feature? From what I can see it isn't hooked up with any user facing feature.

comment:2 Changed 8 years ago by Jannis Leidel

Version: 1.21.3-rc1

comment:3 Changed 8 years ago by Jannis Leidel

Component: Uncategorizeddjango.contrib.staticfiles
Summary: include_patterns in static files finderinclude_patterns in staticfiles finder

comment:4 Changed 8 years ago by Russell Keith-Magee

Resolution: needsinfo
Status: newclosed

Closing needsinfo -- there might be an interesting idea in here, but as Jannis points out, it isn't obvious. The proposed change adds features to an undocumented private API without any obvious public benefit.

Feel free to reopen and elaborate if you feel we have missed something.

comment:5 Changed 7 years ago by German M. Bravo

Cc: German M. Bravo added
Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

Changed 7 years ago by German M. Bravo

Patch updated for 1.4

comment:6 Changed 7 years ago by German M. Bravo

Resolution: needsinfo
Status: closedreopened

I'll elaborate a bit about what I use this for and reopen the ticket as I believe it could be useful for other things as well and it's also elegant and brings symmetry in the code.

I'm using the template system to produce my CSS files, some CSS files I keep in the database with a personalized template loader, some others are in the filesystem. Nonetheless, I also use a CSS compiler (pyScss) to process the produced CSS files. The way I use the include_patterns is in a function I call finder(), which I use to request some given template file(s) in a glob (no matter if it's in the database or the filesystem), finder() returns all the templates that match the given glob, returning the path (if available) and the storage, the same I later use to consistently open and read each file:

    from django.contrib.staticfiles import finders
    def finder(glob):
        for finder in finders.get_finders():
            for path, storage in finder.list([], [glob]):
                yield path, storage

comment:7 Changed 7 years ago by Jannis Leidel

Needs documentation: set
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedDesign decision needed
Type: UncategorizedNew feature

comment:8 Changed 6 years ago by Aymeric Augustin

Status: reopenednew

comment:9 Changed 6 years ago by Aymeric Augustin

Resolution: wontfix
Status: newclosed

I'm sorry, but this doesn't sound like a common use case for Django, and you're using the API for something that's quite far from its goals.

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