Opened 5 years ago

Closed 3 years ago

#15562 closed New feature (wontfix)

include_patterns in staticfiles finder

Reported by: Kronuz Owned by: nobody
Component: contrib.staticfiles Version: 1.3-rc
Severity: Normal Keywords:
Cc: Kronuz 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 Kronuz 5 years ago.
#15562-include_patterns-1.4.diff (5.0 KB) - added by Kronuz 5 years ago.
Patch updated for 1.4

Download all attachments as: .zip

Change History (11)

Changed 5 years ago by Kronuz

comment:1 Changed 5 years ago by jezdez

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 5 years ago by jezdez

  • Version changed from 1.2 to 1.3-rc1

comment:3 Changed 5 years ago by jezdez

  • Component changed from Uncategorized to django.contrib.staticfiles
  • Summary changed from include_patterns in static files finder to include_patterns in staticfiles finder

comment:4 Changed 5 years ago by russellm

  • Resolution set to needsinfo
  • Status changed from new to closed

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 5 years ago by Kronuz

  • Cc Kronuz added
  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

Changed 5 years ago by Kronuz

Patch updated for 1.4

comment:6 Changed 5 years ago by Kronuz

  • Resolution needsinfo deleted
  • Status changed from closed to reopened

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 5 years ago by jezdez

  • Needs documentation set
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Design decision needed
  • Type changed from Uncategorized to New feature

comment:8 Changed 3 years ago by aaugustin

  • Status changed from reopened to new

comment:9 Changed 3 years ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to closed

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