Making key_prefix callable for more flexible caching

2022-01-22 Thread Tobias Kunze
Hi all,

after mostly caching via external tools or manually for years, I've been
trying out Django's built-in caching recently, and have ran into an issue that
I believe could improve the use cases of `cache_page` a lot:

`cache_page`/`CacheMiddleware` take an optional `key_prefix` argument as a
string, falling back to `settings.CACHE_MIDDLEWARE_KEY_PREFIX`.

If this argument could be a callable (getting the current request as
argument), it would be much easier to cache different versions of the page,
for example for users with different access rights, or to make sure newer
changes are reflected by including a version or timestamp in the cache key.

This change was proposed, uhm, 13 years ago, and was closed when the
key_prefix became a site-wide setting. Any arguments for/against re-opening?

  https://code.djangoproject.com/ticket/11269

Additionally, for several of my use cases it would have been very neat to be
able to determine the cache key myself, which is currently generated fairly
deep into the caching stack based on the prefix, the request and so on. While
that's a good default, it makes it harder to interact with the cache from
outside the request-response cycle for the view being cached.
(But that's a bigger ask, because there's less existing infrastructure to pass
down a changed key function – I'd be pretty happy with just a dynamic prefix.)

Best,
Tobias
-- 
Tobias Kunze / rixx (er/he)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/20220122153731.4beyiyepuahiprgu%40cordelia.localdomain.


Reopen ticket #32088, django.contrib.sessions, get_expiry_date() func problem

2022-01-22 Thread ahmad khalili
* Confusing return value in 
SessionStore('some_session') .get_expiry_date(),  example:*

   from datetime import datetime
from django.contrib.sessions.backends.db import SessionStore
my_session = SessionStore()
my_session.get_expiry_date()
# this return new created sessions expiration time(14 days after 
datetime.now()) this is expected and logical but:
  my_session = SessionStore( 'some_session' )
my_session.get_expiry_date()
# this return new created sessions expiration time too, unexpected, this 
should return my_session expiration time

Here in this example django force us using 
*my_session._get_session_from_db().expire_date* instead 
*my_session.get_expiry_date()*, but one simple question: why we should do 
additional work when we saied to django 'we have specific db session?

In last reply in ticket #32088 i described a bit more.






-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/c2d4a4de-b133-44cb-acb1-768e3b6265bbn%40googlegroups.com.


Guidelines to contribute a JavaScript patch

2022-01-22 Thread Jagruti Tiwari
Hi all,

I am a beginner to open source project contributions. Am a working 
professional with one year of experience in Django and three years with 
JavaScript. 

I came across this article 

 that 
speaks of JavaScript patches. I wish to contribute to this area. However, I 
did not find a list of JavaScript issues. 

Any guidelines in this regard would be great.

Thanks,
Jagruti

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/d8cff5bd-b3b2-4acc-87c4-4e86068f429fn%40googlegroups.com.