Skip to content

Conversation

@firekim2
Copy link

@firekim2 firekim2 commented Aug 3, 2018

If I want to reload when templates changes, I should do like this right now:
--reload-extra-file path/to/templates/file1 --reload-extra-file path/to/templates/file2 ......
add every file by file.
I changed config.py to get files like:
--reload-extra-file path/to/templates/*
or
--reload-extra-file path/to/templates/file1 path/to/templates/file2

meta = "FILES"
validator = validate_list_of_existing_files
default = []
default = ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the correct default?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@firekim2 bump on this question.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump firekim2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So really sorry for not following up about this for this long time.
Yes, it is. Since, we are changing the type to str, and parse it. it should be the empty string.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just reviewed the ArgumentParser documentation and tried this a bit in my REPL. Using nargs='+' causes the value to a be a list, so I think we want [] as the default.

@tilgovi
Copy link
Collaborator

tilgovi commented Jan 22, 2019

I like this PR. I'm sorry I missed it before. I want to be sure it works correctly and haven't had a chance to test. My argparse knowledge is weak, but I've been reading the docs lately. If it works correctly, I support it.

@tilgovi
Copy link
Collaborator

tilgovi commented Jan 22, 2019

The other thing I would check is that everything works correctly when this is the last flag. In other words, I would hope that it does not eat the required Python app module argument.

gunicorn --reload-extrafile file1 file2 app should still work.

@trivedigaurav
Copy link

This is useful. Thanks!

@tilgovi
Copy link
Collaborator

tilgovi commented Jan 28, 2019

@firekim2 do you have time or interest to rebase this?

@firekim2
Copy link
Author

@firekim2 do you have time or interest to rebase this?

Yes, I have. Let me try it.

@firekim2
Copy link
Author

@tilgovi rebased it

@benoitc
Copy link
Owner

benoitc commented Jan 29, 2019

@firekim2 thanks! there i still one last question to answer but otherise the change is OK for me :)

@franekmagiera
Copy link

franekmagiera commented Jan 24, 2021

Hi,
stumbled upon this PR while trying to figure out a solution to #1643.

As for your question regarding the default value - I tested "" and []and they both work as expected. This is because the Setting class in its set method assigns the value that is returned from the validator function - and the validator returns [] if the passed value is falsy - both "" and [] are, so there is no error.

Argparse by default treats all arguments as strings so having "" as default makes sense in my opinion. On the other hand, having [] does not rely on the validator doing the checking and substitution.

This also solves #1643 because argparse.ArgumentParser's parse_args methods resolves wildcards such as *json.

@tilgovi @firekim2

@jgod
Copy link

jgod commented Apr 29, 2021

It's been sitting around for a couple years. What does this need to go forward? Just a review from @benoitc @tilgovi or waiting on action from @firekim2 ?

@OrionReed
Copy link

Is there a blocker for this PR? Would really love to have this, or alternatively some kind of workaround as this covers quite a common case.

@nvnieuwk
Copy link

nvnieuwk commented Aug 2, 2022

Any updates on this?

@foobarbecue
Copy link

Please merge!

@manolomono
Copy link

It's necessary when we pass a directory that is applied recursively

@firekim2
Copy link
Author

Anything I can do for merging this?
And Sorry guys somehow alerts went into spam, and I only used GIthub Enterprise for a while!

@wrabit
Copy link

wrabit commented Sep 10, 2023

Anything specifically holding this up? Would love to see this functionality merged

@ShlomoCode
Copy link

ShlomoCode commented Dec 19, 2023

In the meantime, you can use a little bash script:

gunicorn app.wsgi --reload $(find templates -type f -name '*.html' -exec echo --reload-extra-file {} \;)

It tracks changes in every html file in the templates folder (or its subfolder)

@tilgovi
Copy link
Collaborator

tilgovi commented Dec 27, 2023

I've pushed a version of this to #3124, preserving backwards compatibility and adding tests. @firekim2, I've kept you as the commit author and added myself as co-author. If you have a chance to review, that'd be great.

Thanks for your patience on this!

@mpoletto
Copy link

mpoletto commented Mar 26, 2024

The documentation can cause confusion about the theme while doing reference of reload_extra_files (on plural) for the singular parameter --reload-extra-file.

@mfxa
Copy link

mfxa commented Apr 18, 2024

Great suggestion! In my case specifically for reloading on changes to template files, CSS, JS and such.

@benoitc
Copy link
Owner

benoitc commented Aug 6, 2024

no activity since awhile. closing feel free to create a new ticket if needed. Thanks for the patch!

@benoitc benoitc closed this Aug 6, 2024
@mfxa
Copy link

mfxa commented Aug 8, 2024

Is this patch being applied, or the one in #3124 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.