~petersanchez

Los Angeles, CA

https://www.petersanchez.com

LA, CA USA - Managua, Nicaragua

~petersanchez/public-inbox

Last active 25 days ago

~petersanchez/blog-discussion

Last active 3 months ago
View more

Recent activity

Re: [PATCH django-impersonate] optimization | preserve request.user laziness 26 days ago

From Peter Sanchez to ~petersanchez/public-inbox

On 12/22, Илья wrote:
>class ImpersonateMiddleware(MiddlewareMixin):
>    def process_request(self, request):
>        _usr = request.user  # save as local var to prevent infinite recursion
>        def _get_usr():
>            _usr.is_impersonate = False
>            return _usr
>
>        request.user = SimpleLazyObject(_get_usr)
>        request.impersonator = None
>
>        if '_impersonate' in request.session and request.user.is_authenticated:
>            ....

Re: [PATCH django-impersonate] optimization | preserve request.user laziness 27 days ago

From Peter Sanchez to ~petersanchez/public-inbox

Interesting catch. I have some thoughts below.

On 12/21, Илья wrote:
>class ImpersonateMiddleware(MiddlewareMixin):
>    def process_request(self, request):
>        request.user.is_impersonate = False  # <----- this one
>        request.impersonator = None
>
>        if is_authenticated(request.user) and \  # <----- and this one
>           '_impersonate' in request.session:
>            new_user_id = request.session['_impersonate']
>            .....
>
>As a quick-and-dirty fix we can just remove the first line - but in

Re: [PATCH django-impersonate] Downgrade signals logging from warning to debug a month ago

From Peter Sanchez to ~petersanchez/public-inbox

Thanks! This was applied.

On 12/10, Hugo Rodger-Brown wrote:
># HG changeset patch
># User Hugo Rodger-Brown <hugo@yunojuno.com>
># Date 1607608487 0
>#      Thu Dec 10 13:54:47 2020 +0000
># Branch downgrade-logging
># Node ID bd1429321fb4a7f4627448681d369d07875c5edf
># Parent  a174b1c67a73699e1ea51d1433db7d0f22c4e6ef
>Downgrade signals logging from warning to debug

Re: [PATCH django-impersonate] add option for auto-expiring impersonate sesions, implements #45 a month ago

From Peter Sanchez to ~petersanchez/public-inbox

Thank you! I applied this. I did some slight cleanup for formatting
(black) but otherwise left it untouched.

On 11/24, Leonhard Kuboschek wrote:
># HG changeset patch
># User Leonhard Kuboschek <leo@jacobs-alumni.de>
># Date 1606156336 -3600
>#      Mon Nov 23 19:32:16 2020 +0100

Re: [PATCH django-impersonate] add option for auto-expiring impersonate sesions, implements #45 a month ago

From Peter Sanchez to ~petersanchez/public-inbox

On 11/23, Leonhard Kuboschek wrote:
>+from datetime import datetime, timedelta

I wonder if it's not better to use the `django.utils.timezone` module
here? Also use UTC aware timestamps.

>+                start_time = datetime.fromtimestamp(request.session['_impersonate_start'])
>+                if datetime.now() - start_time > timedelta(seconds=settings.MAX_DURATION):

Use `datetime.utcfromtimestamp()` and `timezone.now()` which returns a
UTC aware copy of datetime.now(). We'd have to also use
`timezone.make_aware()` on the `start_time` variable when subtracting.

`if timezone.now() - timezone.make_aware(start_time) > ...`

Re: [PATCH django-impersonate] clean up all warnings. mostly Django 4.0 deprecation a month ago

From Peter Sanchez to ~petersanchez/public-inbox

Thanks! This has been applied.

On 11/19, Leonhard Kuboschek wrote:
># HG changeset patch
># User Leonhard Kuboschek <leo@jacobs-alumni.de>
># Date 1605778760 -3600
>#      Thu Nov 19 10:39:20 2020 +0100
># Node ID 1553f65e1488b9a3ef560fd8aad0c0c04a2722a5
># Parent  926d80a74d429670db210b36fe9815462f6e4a31

Re: [PATCH 1 of 2 py-scfg] Return None when trying to get missing sub-directive 2 months ago

From Peter Sanchez to ~petersanchez/public-inbox

On 11/02, David Keijser wrote:
>Ok, cool. Did the other patch make it to you too?
>
>Having type annotations would be great when writing code using scfg
>because it enables type checking with mypy and nice editor integration
>with langserver and the like.

Hrmm, no. I only got the 1 and checking the mail logs I don't see
multiple emails being submitted yesterday from your email address. Can
you please resend?

>Oof, that's what I get for pasting the first code block I see into
>config files.

Re: [PATCH 1 of 2 py-scfg] Return None when trying to get missing sub-directive 2 months ago

From Peter Sanchez to ~netlandish/email-test-drive

On 11/01, David Keijser wrote:
># HG changeset patch
># User David Keijser <keijser@gmail.com>
># Date 1604248014 -3600
>#      Sun Nov 01 17:26:54 2020 +0100
># Node ID 33f5a3354dc7b1fce8639602d4212da01c7da19a
># Parent  64f694b06df5c2f5140d456de6304804d4d8c8be
>Return None when trying to get missing sub-directive

Thanks! It's been applied and submitted a new version to pypi.

Just a heads up, the proper mailing list for this repo is:

~petersanchez/public-inbox@lists.code.netlandish.com

TLS Checker 5 months ago

From Peter Sanchez to ~petersanchez/public-inbox

Just testing other integrations