Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-25 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 Type:   |  Lazarević
  Cleanup/optimization   |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Alexander Lazarević):

 > I'm not sure we want to go down the path of casting every integer
 setting?

 Maybe this could be part of the system checks? Here as an example only for
 one setting, but could be extended to more settings as well.

 {{{
 @register(Tags.files)
 def check_settings_types(app_configs, **kwargs):
 setting = getattr(settings, "CACHE_MIDDLEWARE_SECONDS", None)
 if setting and not isinstance(setting, int):
 return [
 Error(
 "The CACHE_MIDDLEWARE_SECONDS setting should be an
 integer.",
 id="files.E002",
 )
 ]
 return []
 }}}
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d44028299-4eca6e88-cd53-4250-8b6c-2534c58c0bb8-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-25 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 Type:   |  Lazarević
  Cleanup/optimization   |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Alexander Lazarević):

 * needs_docs:  1 => 0
 * needs_tests:  1 => 0

Comment:

 I changed the PR accordingly
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d43b91100-44ab3b4f-a088-40ee-b073-52cdd93f8e35-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-25 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 Type:   |  Lazarević
  Cleanup/optimization   |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Alexander Lazarević):

 Ok in #35041 it's been said that

 > ... however we cannot add type checks for all settings. It's documented
 as integer and Django crashes when you use it incorrectly, so it's hard to
 miss.

 Well currently a float for CACHE_MIDDLEWARE_SECONDS will just work, but
 produce the wrong value for max_age, which is easy to miss.

 But looking forward I have a draft PR for #27225 that will make Django
 crash, when CACHE_MIDDLEWARE_SECONDS is a float. So this would be a harsh
 indicator that the setting for CACHE_MIDDLEWARE_SECONDS is wrong.

 '''With that I'm suggesting I change the PR for this ticket to "just" fix
 the comment and the setting in the testcase? What do you think?'''

 Regardless of that, maybe two more thoughts:

 > Certainly, but I wonder if it's Django's responsibility (and any third-
 party code that uses the setting) to silently correct such a mistake.

 In this case I would rather want Django sillently do the right thing than
 silently do the wrong thing.

 > I'm not sure we want to go down the path of casting every integer
 setting?

 I think we shouldn't make the perfect (type checking every setting) the
 enemy of the good (fixing one particular problem with one setting). In
 general.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d43a177a1-7a144c68-36b9-4e06-bbbe-f905ccf7fb5c-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-25 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 Type:   |  Lazarević
  Cleanup/optimization   |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Tim Graham):

 Certainly, but I wonder if it's Django's responsibility (and any third-
 party code that uses the setting) to silently correct such a mistake. I
 see some precedent in #31982 although there isn't much elaboration on the
 rationale.

 If we are going down this route, should reopen #35041 and do the same (as
 well as do a more extensive audit throughout Django and handle this
 pattern proactively)?
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d413f930b-901e09b6-165a-4a2c-b603-da6c8575162f-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-25 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 Type:   |  Lazarević
  Cleanup/optimization   |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Alexander Lazarević):

 But a float for `max-age` is definitely wrong.

 {{{
 'Cache-Control': 'max-age=3.1415927'
 }}}
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d40f11400-bde52635-0f31-42d8-9eea-c2f1f0747408-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-25 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 Type:   |  Lazarević
  Cleanup/optimization   |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Tim Graham):

 I'm not sure we want to go down the path of casting every integer setting?
 (e.g. #35041 for `DATA_UPLOAD_MAX_MEMORY_SIZE` was recently a wontfix.)
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d40ba3c67-e13bc674-20d9-40c5-b05d-fa1af5875377-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-24 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 Type:   |  Lazarević
  Cleanup/optimization   |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_docs:  0 => 1
 * needs_tests:  0 => 1

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d3eeae46c-6316300f-82d6-4b5d-9c73-eaff8651b515-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-24 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 Type:   |  Lazarević
  Cleanup/optimization   |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * type:  Bug => Cleanup/optimization
 * stage:  Unreviewed => Accepted

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d3ee2366d-dd62ccc9-a893-4b18-8a8d-f8ba9bd41e4e-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-24 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  Alexander
 |  Lazarević
 Type:  Bug  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Alexander Lazarević):

 * owner:  nobody => Alexander Lazarević
 * status:  new => assigned
 * has_patch:  0 => 1

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d3ec654c4-64479a51-b73d-4a3d-89ea-084db9ae32bd-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-24 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Alexander Lazarević):

 Created a PR https://github.com/django/django/pull/17776
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d3ec5df78-614c0710-9f30-4c64-839d-22f190b1c4a0-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-24 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Alexander Lazarević):

 The testcase in question produces a `TemplateResponse` like this:

 {{{
 
 {'Content-Type': 'text/html; charset=utf-8', 'Expires': 'Thu, 25 Jan 2024
 03:19:03 GMT', 'Cache-Control': 'max-age=2.0'}
 }}}

 And from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-
 Control

 "The max-age=N response directive indicates that the response remains
 fresh until N seconds after the response is generated."

 Where N is an int
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d3ec0c943-fcc3e34f-6591-4f4e-bbef-66cdcc9b25e4-00%40eu-central-1.amazonses.com.


Re: [Django] #35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int

2024-01-24 Thread Django
#35141: CACHE_MIDDLEWARE_SECONDS can be set to a float but has to be an int
-+-
 Reporter:  Alexander Lazarević  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Alexander Lazarević):

 This is related to https://code.djangoproject.com/ticket/27225
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d3eb4f70a-64dbaa1a-3129-4ffa-88b9-a12ac59afcbc-00%40eu-central-1.amazonses.com.