Re: Proposal for a transaction.on_before_commit

2021-10-12 Thread Raphael Michel
Hi Aymeric,

thank you for the insightful reply. Indeed I have overlooked the issue
with savepoints which makes it much more fragile. In our case, "not
using savepoint rollbacks any more" would be a trade-off that we'd
happily make (there are enough other problems with savepoints to begin
with), but I understand that this kinda disqualifies it for a
first-class feature in Django :(

A middleware is not an option for us, as we intentionally don't use
ATOMIC_REQUESTS and not all code is triggered through requests (celery
tasks, management commands, …) and we'd like to avoid to deal with all
of these separately.

Best
Raphael

Am Sun, 10 Oct 2021 21:38:13 +0200
schrieb Aymeric Augustin :

> Hello Raphael,
> 
> Oh - a use case for django-transaction-signals
>  ;-) I'm
> bringing up this elaborate joke because you're essentially asking for
> a "pre-commit" signal here and the README contains a good list of
> things that can go wrong with transaction signals. (Please ignore how
> this package demonstrates a way to do it as third-party code *cough*
> *cough* *cough*)
> 
> > I figured a perfect way to do this would be using `save()` or
> > `post_save` to add the changed model instance to some kind of
> > thread-local list, and then using `transaction.on_commit` to
> > "schedule" the aggregation and create the log entries when all
> > changes have been made. However, this obviously is not a good
> > enough because `on_commit` runs *after* the `COMMIT` statement and
> > thus we're not guaranteed that all log entries are persisted to the
> > database.  
> 
> 
> In my opinion "saving the log entries may fail after a successful
> transaction" isn't the main design problem here. The bigger problem
> is "log may contain entries for writes that don't actually happen,
> because some savepoints were rolled back, typically due to atomic
> blocks exiting with an exception". And then you get dragged into the
> whole complexity that the README of django-transaction-signals
> outlines and that we're trying to avoid in Django.
> 
> (If you don't have any savepoint rollbacks, then your code sounds
> sufficiently constrained to implement logging of changes explicitly
> at the application layer rather than at the framework layer.)
> 
> If you run with ATOMIC_REQUESTS, I would suggest to replace it by a
> custom middleware that wraps get_response(request) in an atomic
> block. Then you know that this is the outermost traction and you can
> do whatever needed before exiting the atomic block. You also need the
> same in all management commands, which could be a problem if you
> depend on third-party management commands.
> 
> Failing that, in order to log changes with transactional correctness
> enforced by the ACID guarantees of PostgreSQL, I'd recommend doing it
> at that database level with triggers — which always execute in the
> same transaction. I realize it may be difficult to perform the kind
> of aggregation you have in mind.
> 
> As a last resort, I'd try a custom database backend to track
> accurately transactions and savepoints and maintain an up-to-date
> record of changes that will happen when the transaction is committed.
> 
> Hope this helps!
> 

-- 
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/20211012112820.57a47da3%40kvothe.


Re: Proposal for a transaction.on_before_commit

2021-10-12 Thread Raphael Michel
Hi,

Am Sun, 10 Oct 2021 18:38:55 +0300
schrieb Shai Berger :
> Why is a before-commit signal preferable to a vanilla Python
> context-manager around the code? Or, if it is in the context of
> requests, a middleware?

basically mostly because you can forget to put the context manager
around it and because it might become very verbose adding context
managers everywhere.

Best
Raphael

-- 
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/20211012112913.26138880%40kvothe.


Re: (Circa end of 2021) Localization issues with input type=date?

2021-10-12 Thread Carlton Gibson
Thank you all, yes — there's some good points there. (Some others raised on 
the PR and the ticket too.) 

It's looks like there are still some caveats, and describing those 
succinctly remains to do. 
👍

Kind Regards,

Carlton


On Wednesday, 29 September 2021 at 21:13:51 UTC+2 Tobias Bengfort wrote:

> > Back then there were various issues with localisation when **not** 
> using type=text.
>
> As https://code.djangoproject.com/ticket/16630#comment:11 states: the 
> inputs only accept a special format. To make it work I had to explicitly 
> set the format: `DateInput(format='%Y-%m-%d', attrs={'type': 'date'}`.
>
> Another thing to be aware of: The native date picker UI uses the 
> system/browser locale, not the one that is used on the page. (See also 
> https://bugs.chromium.org/p/chromium/issues/detail?id=263320)
>
> Hope that helps
>
> tobias
>

-- 
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/5c785fe6-396e-481e-9107-7928071912can%40googlegroups.com.


Re: Fellow Reports - September 2021

2021-10-12 Thread Mariusz Felisiak
Week ending September 26, 2021 

Released Django 4.0a1. 

*Triaged: *
   https://code.djangoproject.com/ticket/33120 - Add OGC-compliant models 
for GeoDjango running on MySQL 8.0 (accepted) 
   https://code.djangoproject.com/ticket/33121 - Mention custom users in 
the tutorial 02. (wontfix) 
   https://code.djangoproject.com/ticket/33117 - sitemap.xml template used 
with alternates for multiple languages returns an invalid xml (invalid) 
   https://code.djangoproject.com/ticket/33119 - Change casing of a model's 
name referenced by ManyToManyField generates unnecessary migrations. 
(fixed) 
   https://code.djangoproject.com/ticket/33123 - Django admin urls are not 
working, they just redirect to back to the admin root. (invalid) 
   https://code.djangoproject.com/ticket/33127 - "&" and "|" operators are 
silently ignored after QuerySet.union(), intersection(), and difference(). 
(accepted) 
   https://code.djangoproject.com/ticket/33124 - Avoid accessing 
ConnectionsHandler.__getitem__ until it's strictly necessary. (accepted) 
   https://code.djangoproject.com/ticket/33125 - Changing model field to 
become PK creates redundant UNIQUE constraint (accepted) 
   https://code.djangoproject.com/ticket/33129 - Drop support for MariaDB 
10.2. (created) 
   https://code.djangoproject.com/ticket/33130 - ErrorDict doesn't pass the 
dict type check in JsonResponse. (accepted) 
   https://code.djangoproject.com/ticket/33133 - NullBooleanField doesn't 
work in historical migrations. (created) 
   https://code.djangoproject.com/ticket/33134 - Circular contexts when 
rendering Form with BoundFields. (created) 
   https://code.djangoproject.com/ticket/33135 - Add read_only parameter to 
Model fields for virtual columns. (duplicate) 
   https://code.djangoproject.com/ticket/33138 - Tuple comparison for 
efficient lexicographic ordering on multiple columns (duplicate) 

*Reviewed/committed: *
   https://github.com/django/django/pull/14709 - Fixed #32970 -- Changed 
WhereNode.clone() to create a shallow copy of children. 
   https://github.com/django/django/pull/14867 - Refs #33119 -- Added tests 
for changing model name case referenced by ManyToManyField. 
   https://github.com/django/django/pull/14865 - Refs #27624 -- Optimized 
Query.clone() for non-combined queries. 
   https://github.com/django/django/pull/14819 - Fixed #31026 -- Switched 
form rendering to template engine. 
   https://github.com/django/django/pull/14871 - Fixed #33070 -- Fixed 
loading translations with language subtags in admin's Select2 widget. 
   https://github.com/django/django/pull/14861 - Fixed #33111 -- Fixed 
passing object to ModelAdmin.get_inlines() when editing in admin change 
view. 
   https://github.com/django/django/pull/14870 - Fixed #33083 -- Fixed 
selecting all items in the admin changelist when actions are both top and 
bottom. 
   https://github.com/django/django/pull/14877 - Removed blocking wait in 
admin inlines selenium test. 
   https://github.com/django/django/pull/13944 - Optimized handling 
case-insensitive mappings. 
   https://github.com/django/django/pull/14385 - Fixed #32499 -- Removed 
additional metacharacters in simplify_regex(). 
   https://github.com/django/django/pull/14890 - Fixed #33127 -- Added 
error messages on | and & operators with combined querysets. 
   https://github.com/django/django/pull/14884 - Fixed #33130 -- Restored 
form errors to be a dict. 
   https://github.com/django/django/pull/14876 - Fixed #33124 -- Avoided 
accessing the database connections when not necessary. 
   https://github.com/django/django/pull/14893 - Removed obsolete GEOS 3.5 
requirement note. 

*Authored: *
   https://github.com/django/django/pull/14872 - [4.0.x] Updated source 
translation catalogs. 
   https://github.com/django/django/pull/14873 - Fixed broken links and 
redirects in docs. 
   https://github.com/django/django/pull/14874 - Refs #31026 -- Fixed 
forms_tests if Jinja2 is not installed. 
   https://github.com/django/django/pull/14881 - Fixed #33129 -- Dropped 
support for MariaDB 10.2. 
   https://github.com/django/django/pull/14882 - Skipped GitHub actions for 
linters and JavaScript tests on purely doc changes. 
   https://github.com/django/django-contrib-comments/pull/146 - Added 
testing for Django 3.0.

Best,
Mariusz

-- 
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/9bc06bbe-af0a-48c1-8f6e-50d03b083f80n%40googlegroups.com.


Re: Fellow Reports - September 2021

2021-10-12 Thread Mariusz Felisiak
Week ending October 3, 2021 

*Triaged: *
   https://code.djangoproject.com/ticket/33144 - get_elided_page_range() 
method doesn't work properly. (invalid) 
   https://code.djangoproject.com/ticket/33146 - Wrong command in ASGI 
deployment-guide using uvicorn (invalid) 
   https://code.djangoproject.com/ticket/33147 - django-admin runserver 
--settings=mysite.settings errors out (worksforme) 
   https://code.djangoproject.com/ticket/33141 - Rename 
Aggregate.empty_aggregate_value to empty_result_set_value. (accepted) 
   https://code.djangoproject.com/ticket/33148 - Set `Cache-Control: 
max-age=0` header on static files response so that files are easily 
refreshable during development (duplicate) 
   https://code.djangoproject.com/ticket/33139 - Using IPython for the 
manage.py REPL interface clobbers __main__, where the normal python REPL 
doesn't. (wontfix) 
   https://code.djangoproject.com/ticket/33149 - Make --pdb work with 
subTest(). (accepted) 
   https://code.djangoproject.com/ticket/33131 - Improve error messages for 
reverse accessor clashes. (accepted) 
   https://code.djangoproject.com/ticket/33150 - EmailBackend.write_message 
crashes when self.steam is BufferedWriter (invalid) 
   https://code.djangoproject.com/ticket/33153 - "database table is locked" 
error on SQLite when testing with mirror database (duplicate) 
   https://code.djangoproject.com/ticket/33154 - The Exact lookup generates 
suboptimal queries for BooleanField on MySQL (duplicate) 
   https://code.djangoproject.com/ticket/33152 - Document the fact that a 
DB connection can be closed mid-request when a HTTP client disconnects 
prematurely (invalid) 
   https://code.djangoproject.com/ticket/33151 - createsuperuser doesn't 
work in non-interactive mode if a ManyToManyField/ForeignKey is in 
REQUIRED_FIELDS. (accepted) 
   https://code.djangoproject.com/ticket/33155 - ModelChoiceIteratorValue 
is not hashable. (accepted) 
   https://code.djangoproject.com/ticket/33157 - Consider back-porting the 
fix of #32889 to version 3.2.x (wontfix) 
   https://code.djangoproject.com/ticket/33156 - Admin Sidebar search value 
stays forever (accepted) 
   https://code.djangoproject.com/ticket/33159 - Missing table alias in 
generated query after used in subquery (accepted) 
   https://code.djangoproject.com/ticket/33160 - 
DatabaseWrapper._nodb_cursor() raises wrong warnings in case of errors from 
queries on PostgreSQL. (accepted) 
   https://code.djangoproject.com/ticket/32961 - Add support for BIT_XOR 
aggregate in PostgreSQL 14+. (accepted) 
   https://code.djangoproject.com/ticket/32943 - Add support for covering 
indexes and exclusion constraints for SP-GiST in PostgreSQL 14+. (accepted) 
   https://code.djangoproject.com/ticket/33161 - Do not ignore transaction 
durability errors within TestCase (accepted) 
   https://code.djangoproject.com/ticket/33162 - Add __file__ to Settings. 
(wontfix)

*Reviewed/committed: *
   https://github.com/django/django/pull/14898 - Fixed #33114 -- Defined 
default output_field of StringAgg. 
   https://github.com/django/django/pull/14897 - Refs #32355 -- Modernized 
subprocess.run() calls. 
   https://github.com/django/django/pull/14892 - Fixed #33136 -- Added 
GEOSGeometry.make_valid() method. 
   https://github.com/django/django/pull/14896 - Fixed #33125 -- Avoided 
redundant unique constraint when converting a non-unique field to primary 
key on MySQL and PostgreSQL. 
   https://github.com/django/django/pull/14785 - Fixed #33033 -- Prevented 
models.DecimalField from accepting NaN values. 
   https://github.com/django/django/pull/14903 - Fixed #33134 -- Fixed 
recursion depth error when rendering Form with BoundFields. 
   https://github.com/django/django/pull/14771 - Fixed #33027 -- Made 
autoreloader pass -X options. 
   https://github.com/django/django/pull/14894 - Fixed #33141, Fixed #33018 
-- Fixed annotations with empty queryset. 
   https://github.com/django/django/pull/14915 - Fixed #33155 -- Made 
ModelChoiceIteratorValue instances hashable. 
   https://github.com/django/django/pull/14918 - Fixed #33160 -- Avoided 
suppressing query errors in _nodb_cursor() on PostgreSQL. 
   https://github.com/django/django/pull/14689 - Fixed #32961 -- Added 
BitXor() aggregate to django.contrib.postgres. 
   https://github.com/django/django/pull/14663 - Fixed #32943 -- Added 
support for covering indexes and exclusion constraints for SP-GiST on 
PostgreSQL 14+.

*Authored: *
   https://github.com/django/django/pull/14908 - Corrected field and model 
check messages in docs. 
   https://github.com/django/django/pull/14916 - Fixed #33159 -- Reverted 
"Fixed #32970 -- Changed WhereNode.clone() to create a shallow copy of 
children."
   https://github.com/django/django-docker-box/pull/32 - Used 
PyMemcacheCache instead of MemcachedCache backend.

Best,
Mariusz

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscrib

Fellow Reports - October 2021

2021-10-12 Thread Mariusz Felisiak

Week ending October 10, 2021

*Triaged:*
    https://code.djangoproject.com/ticket/33164 - UUID URL converter 
should support uppercase hexadecimal digits (wontfix)
    https://code.djangoproject.com/ticket/32888 - Document that 
select_for_update() doesn't lock tables when their columns are not 
selected. (accepted)
    https://code.djangoproject.com/ticket/33165 - DateInput default 
date is not shown when localization is on (needsinfo)
    https://code.djangoproject.com/ticket/33163 - Add AppConfig.ready() 
example to the admonition about connecting receiver functions. (accepted)
    https://code.djangoproject.com/ticket/33168 - Meta.managed=False 
field not respected by makemigrations (wontfix)
    https://code.djangoproject.com/ticket/33169 - Migrations crashes 
with long identifiers on MySQL. (needsinfo)
    https://code.djangoproject.com/ticket/32074 - Python 3.10 
compatibility (accepted)
    https://code.djangoproject.com/ticket/33173 - Python 3.11 
compatibility (created)
    https://code.djangoproject.com/ticket/33166 - Add "field" to the 
context when rendering widgets. (accepted)
    https://code.djangoproject.com/ticket/28401 - Allow hashlib.md5() 
calls to work with FIPS kernels (accepted)
    https://code.djangoproject.com/ticket/21241 - Optimize the query 
generated for admin changelist filters (duplicate)
    https://code.djangoproject.com/ticket/33175 - ForeignKeyRawIdWidget 
doesn't quote object.pk and generates wrong links. (duplicate)
    https://code.djangoproject.com/ticket/33177 - Setting 
DATABASES[alias]["TEST"]["MIGRATE"] = False should mean that `migrate` 
isn't run. (wontfix)
    https://code.djangoproject.com/ticket/33180 - Debug 500 HTML broken 
with strict Content-Security-Policy (CSP) (accepted)


*Reviewed/committed:*
    https://github.com/django/django/pull/14930 - Refs #27694 -- Doc'd 
lookups that can be chained with HStoreField key transforms.
    https://github.com/django/django/pull/14931 - Refs #33107 -- 
Optimized cached_import() helper.
    https://github.com/django/django/pull/14891 - Fixed #32888 -- Doc'd 
that select_for_update() only locks tables with selected columns.
    https://github.com/django/django/pull/14920 - Fixed #4 -- Added 
note about supplying missing values for non-nullable fields with blank=True.
    https://github.com/django/django/pull/14936 - Refs #29026 -- Added 
log() to makemigrations.
    https://github.com/django/django/pull/14947 - Refs #26430 -- 
Removed unused branch in sql.Query.get_count().
    https://github.com/django/django/pull/14935 - Fixed #23408 -- Added 
migrations questioner prompt for adding unique fields with a callable 
default.
    https://github.com/django/django/pull/14917 - Fixed #33156 -- Used 
sessionStorage to preserve quick filter for admin's navigation sidebar.
    https://github.com/django/django/pull/14880 - Fixed #33131 -- 
Improved error messages for clashing reverse accessor names.
    https://github.com/django/django/pull/14924 - Refs #31026 -- 
Improved BoundField.label_tag() docs.
    https://github.com/django/django/pull/14954 - Fixed #33151 -- Fixed 
createsuperuser crash for many-to-many required fields in 
non-interactive mode.
    https://github.com/django/django/pull/14927 - Refs #25467 -- Added 
test for excluding one-to-one relation with unsaved objects.
    https://github.com/django/django/pull/14944 - Improved docs 
regarding UTF-8 support with Apache and mod_wsgi.


*Reviewed:*
    https://github.com/django/django/pull/14941 - Refs #33029 -- Fixed 
popups Selenium tests in headless mode.


*Authored:*
    https://github.com/django/django/pull/14937 - Refs #32074 -- Added 
Python 3.10 to classifiers and tox.ini.
    https://github.com/django/django/pull/14940 - [3.2.x] Refs #32074 
-- Used asyncio.get_running_loop() instead of get_event_loop() on Python 
3.7+.
    https://github.com/django/django/pull/14942 - Refs #32074 -- Doc'd 
Python 3.10 compatibility in Django 3.2.x.
    https://github.com/django/django/pull/14957 - Fixed #33022 -- Fixed 
isolation of migrations.test_executor.ExecutorTests.test_custom_user().


Best,
Mariusz

--
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/ef7d51bd-7080-1ffb-0dbf-ed5569f9a17f%40gmail.com.