Code

Opened 3 years ago

Closed 16 months 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

Description

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 3 years ago.
#15562-include_patterns-1.4.diff (5.0 KB) - added by Kronuz 2 years ago.
Patch updated for 1.4

Download all attachments as: .zip

Change History (11)

Changed 3 years ago by Kronuz

comment:1 Changed 3 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 3 years ago by jezdez

  • Version changed from 1.2 to 1.3-rc1

comment:3 Changed 3 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 3 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 3 years ago by Kronuz

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

Changed 2 years ago by Kronuz

Patch updated for 1.4

comment:6 Changed 2 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 2 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 16 months ago by aaugustin

  • Status changed from reopened to new

comment:9 Changed 16 months 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.