Re: reg: Django custom middleware

2024-01-24 Thread ASAMOAH EMMANUEL
t; Hi All, > > I have written a *custom Django middleware* to do* retries and catch > exception* if there is *any connection related issues* between two > servers. *Below is the code snippet.* > > from requests.adapters import Retry, RetryError, HTTPAdapter, > MaxRetryError,

reg: Django custom middleware

2024-01-24 Thread 'Amitesh Sahay' via Django users
Hi All, I have written a custom Django middleware to do retries and catch exception if there is any connection related issues between two servers. Below is the code snippet. from requests.adapters import Retry, RetryError, HTTPAdapter, MaxRetryError, ConnectTimeoutError, ProtocolError

Re: Prevent Multiple Device Login for a User in Django using Middleware

2021-03-14 Thread Saurabh Pandey
did you get answer, can u tell here plz? On Thursday, 13 August, 2020 at 12:52:29 am UTC+8 RAMIRO MAGAÑA wrote: > Prevent Multiple Device Login for a User in Django using Middleware > -- You received this message because you are subscribed to the Google Groups "Django users

channels - async consumer behind sync middleware

2020-11-04 Thread Özgür Akçalı
I am using async consumers, and everything they do is async, except for a middleware. I have a custom authentication middleware that connects to the database and runs 2-3 queries. It is suggested in the docs that if anything non-async is done in the consumer, we should use sync consumers

Prevent Multiple Device Login for a User in Django using Middleware

2020-08-12 Thread RAMIRO MAGAÑA
Prevent Multiple Device Login for a User in Django using Middleware -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@google

Django Middleware vs. DRF Permission Classes for Validations

2019-10-17 Thread Dinesh Dass Subramanian
some will be applicable to APIs on a need basis. I need to know the best approach on whether I could have a custom middleware for validations based on API endpoints or should I use Permission classes of DRF for validations based on API endpoints? -- You received this message because you are

KeyError for CSRF middleware during processing an exception response

2019-09-11 Thread Most. Runa
Fuck me +8801737940981 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https

KeyError for CSRF middleware during processing an exception response

2019-09-11 Thread Timothy Gates
If an exception response occurs during the middleware processing it looks like the CSRF middleware layer can obscure the issue by getting a KeyError exception of its own. The request.META does not contain the CSRF_COOKIE but the response handling seems to assume it has already been set. I get

Re: Running pending migrations in Middleware

2019-07-28 Thread David Grant
On Sunday, July 28, 2019 at 2:35:03 PM UTC-7, David Grant wrote: > > > I'm using Google AppEngine and I have no access to the server. The > alternative is to have the exact same code checked out on my local machine. > Connect to the remote database with a special proxy tool that google > provi

Re: Running pending migrations in Middleware

2019-07-28 Thread David Grant
On Sunday, July 28, 2019 at 10:10:57 AM UTC-7, James Schneider wrote: > > > > On Sun, Jul 28, 2019, 12:47 AM David Grant > wrote: > >> Anyone see any problems with running migrations in Middleware? >> > > What's the actual problem you are trying to solve

Re: Running pending migrations in Middleware

2019-07-28 Thread David Grant
tions, thus causing production to be broken. Thanks for bringing up those points. All middleware are run for every request Yep, this is an issue if "migrate" is called on every request. I solved this by recording whether or not migrations have been run or not on the current ver

truncated response content in middleware

2019-07-28 Thread Václav Mach
Hi, i'm trying to build my own middleware for server side javascript prerending. It's currently very simple (see attachment). It seems to be working fine for few pages but for some other pages the reponse.content is somehow truncated (line 20). The reponse.content is truncated a

Re: Running pending migrations in Middleware

2019-07-28 Thread James Schneider
On Sun, Jul 28, 2019, 12:47 AM David Grant wrote: > Anyone see any problems with running migrations in Middleware? > What's the actual problem you are trying to solve by doing this? This is a bad idea for a number of reasons, and I can't think of any good ones. -James > --

Re: Running pending migrations in Middleware

2019-07-28 Thread Markus Holtermann
Yes, I do see several problems. Some of them: - All middleware are run for every request - What you're doing can slow down your request response time to minutes, depending on home many migrations you have - Depending on your database, migrations might not be atomic thus causing conflicts

Running pending migrations in Middleware

2019-07-28 Thread David Grant
Anyone see any problems with running migrations in Middleware? import logging import os import time from django.core.management import call_command from django.http import HttpResponse from products.models.models import AppVersion LOG = logging.getLogger(__name__) # Used for testing locally

Write queryset containing request from middleware outside of django's views

2019-05-21 Thread valentin jungbluth
Hello guys, I have a little question about request attribute in my function located in a menu.py file (not my view): def list_of_edition(request): """ Return list of editions :return queryset """ instance = NavbarMenuSettings.objects.filter(application=request.cur_app , display=T

What is the difference between declaring a middleware in "MIDDLEWARE" setting vs inside ProtocolTypeRouter()?

2019-02-19 Thread Aung Khant
Hello, I am a new user to Django and Channels. As I mentioned, I believe you can infer from the title what I am getting at. Is it because one has to do with Channel and thus different way of using middleware? -- You received this message because you are subscribed to the Google Groups

django middleware return response and prevent calling main function

2019-01-07 Thread Samuel Muiruri
I want to use a form of cache using django middleware/context-processors. I do know it's simpler to just add the decorator at the top of the function but for reasons I have to do it this way. Using this as my example of my function def cache_results(request): res

Using Django middleware with web and mobile app

2018-11-12 Thread lakshitha kumara
Hello Guys, I'm developing a mobile app and website with one Django backend. all web browser(mobile browser included) using session auth and mobile app using Rest API with OAuth 2 authentications. I would like to know the best way to handle Django middleware with web and mobile app.

Re: Adding to all templates context via Middleware

2018-05-14 Thread Melvyn Sopacua
On maandag 7 mei 2018 17:59:02 CEST Daniel Roseman wrote: > I still don't understand what is being repeated or why. You need to specify > that in your settings, and you can add whatever context processors you > like. You don't need to specify it twice, so nothing is being repeated. What Bernd mean

Re: Adding to all templates context via Middleware

2018-05-07 Thread Daniel Roseman
I still don't understand what is being repeated or why. You need to specify that in your settings, and you can add whatever context processors you like. You don't need to specify it twice, so nothing is being repeated. -- You received this message because you are subscribed to the Google Groups

Re: Adding to all templates context via Middleware

2018-05-06 Thread Bernd Wechner
lly collected until the whole response is rendered. To wit I have done it by inserting stats just before tag as a safe and clean bet. The result is here: https://github.com/bernd-wechner/CoGs/blob/develop/django_stats_middleware/__init__.py Works well for me and is a good hook for inserting

Re: Django-channels request depending Middleware

2018-05-04 Thread Andrew Godwin
That's correct - Django middleware only runs on HTTP request objects, and so doesn't work in a WebSocket context. The recommended alternative is to write ASGI middleware for this purpose. Unfortunately, there is not good documentation on this yet, but you can see a bit about it he

Django-channels request depending Middleware

2018-05-04 Thread Marius Räsener
Hey everybody, We are using a Middleware to inject postgresql schemas into queries based on a subdomain. You can have a look how it‘s done here: https://github.com/systori/systori/blob/dev/systori/apps/company/middleware.py Now, for channels I‘ve noticed that there is no usual request, right

Re: Adding to all templates context via Middleware

2018-05-03 Thread Daniel Roseman
On Thursday, 3 May 2018 01:36:26 UTC+1, Bernd Wechner wrote: > > This interests me: > > > https://teamtreehouse.com/community/django-how-can-i-retrieve-a-value-from-the-middleware > > alas no answer there, and time has changed things. > > I have checked form expe

Adding to all templates context via Middleware

2018-05-02 Thread Bernd Wechner
This interests me: https://teamtreehouse.com/community/django-how-can-i-retrieve-a-value-from-the-middleware alas no answer there, and time has changed things. I have checked form experience, that stuff added to response.context_data in middleware is not seen in templates (perhaps comes

Adding to all templates context via Middleware

2018-05-01 Thread Bernd Wechner
This interests me: https://teamtreehouse.com/community/django-how-can-i-retrieve-a-value-from-the-middleware alas no answer there, and time has changed things. I have checked form experience, that stuff added to response.context_data in middleware is not seen in templates (perhaps comes too

Re: Mysql is gone away auth middleware channels 2

2018-04-05 Thread Matteo Lucchesi
nnels.readthedocs.io/en/latest/topics/databases.html#database-sync-to-async > > Andrew > > On Thu, Apr 5, 2018 at 5:25 AM, Matteo Lucchesi > wrote: > >> https://codeshare.io/5wlXNK >> >> Il giorno giovedì 5 aprile 2018 14:07:56 UTC+2, Matteo Lucchesi ha >>

Re: Mysql is gone away auth middleware channels 2

2018-04-05 Thread Andrew Godwin
chesi wrote: > https://codeshare.io/5wlXNK > > Il giorno giovedì 5 aprile 2018 14:07:56 UTC+2, Matteo Lucchesi ha scritto: >> >> i've write a auth middleware for django channels : >> >> https://codeshare.io/aYnQmN >> >> but seem that use a persi

Re: Mysql is gone away auth middleware channels 2

2018-04-05 Thread Matteo Lucchesi
https://codeshare.io/5wlXNK Il giorno giovedì 5 aprile 2018 14:07:56 UTC+2, Matteo Lucchesi ha scritto: > > i've write a auth middleware for django channels : > > https://codeshare.io/aYnQmN > > but seem that use a persistent connection and after some hour i have the >

Mysql is gone away auth middleware channels 2

2018-04-05 Thread Matteo Lucchesi
i've write a auth middleware for django channels : https://codeshare.io/aYnQmN but seem that use a persistent connection and after some hour i have the erro "Mysql is gone away" Where is the error? -- You received this message because you are subscribed to the Google Groups

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-16 Thread knbk
er market. About 40% of users would still be vulnerable to CSRF attacks. IMO that's too large a chunk of users to leave unprotected. When this feature reaches maturity it will likely be a good option to combat CSRF, but right now it doesn't provide adequate protection on its own. Djan

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-16 Thread Etienne Robillard
26 AM, Etienne Robillard > wrote: Hi Stephan, I'm also interested to understand why I should have some form of CSRF protection for my wsgi app... perhaps recoding the Django 1.11 CSRF middleware into a proper WSGI application (CSRFControlle

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-16 Thread knbk
; I'm also interested to understand why I should have some form of CSRF >> protection for my wsgi app... >> >> perhaps recoding the Django 1.11 CSRF middleware into a proper WSGI >> application (CSRFController) would help. >> >> but seriously, i don't us

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-16 Thread knbk
it_Cookie On Monday, January 15, 2018 at 11:03:22 PM UTC+1, Stephan Doliov wrote: > > Just curious, I recently went on a source code studying binge and took a > look at the CSRF middleware that comes with Django. I appreciate the work > and effort of the authors, but I am not sure I gain a

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-16 Thread Etienne Robillard
to:secur...@djangoproject.com>. On Tue, Jan 16, 2018 at 1:26 AM, Etienne Robillard <mailto:tkad...@yandex.com>> wrote: Hi Stephan, I'm also interested to understand why I should have some form of CSRF protection for my wsgi app... perhaps recoding the Django 1.

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-16 Thread James Bennett
protection for my wsgi app... > > perhaps recoding the Django 1.11 CSRF middleware into a proper WSGI > application (CSRFController) would help. > > but seriously, i don't use/recommend the Django CSRF middleware because it > does not improve security of forms processing. >

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-16 Thread Etienne Robillard
Hi Stephan, I'm also interested to understand why I should have some form of CSRF protection for my wsgi app... perhaps recoding the Django 1.11 CSRF middleware into a proper WSGI application (CSRFController) would help. but seriously, i don't use/recommend the Django CSRF

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-16 Thread James Bennett
The base CSRF secret is per-user, not global. So while you could write a script to hit a page over and over and harvest CSRF tokens, those tokens would only be valid for the session/user associated with your script. Attempting to use them to execute a CSRF attack against another user would fail (si

Re: Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-15 Thread Antonis Christofides
Hi, > 1) Write a script that just harvests the middleware token from a form > "protected" with such token and use the value of that as the csrftoken cookie. You visit web site A (the attacker). Web site A wants to send a malicious POST request to site D (a Django app). The thing

Is CSRF middleware to be taken seriously (from a XSRF point of view)?

2018-01-15 Thread Stephan Doliov
Just curious, I recently went on a source code studying binge and took a look at the CSRF middleware that comes with Django. I appreciate the work and effort of the authors, but I am not sure I gain anything by deploying it to my site. Here is why: The middleware token assigned to a form and to

Re: uwsgi stats middleware for Django

2017-12-09 Thread Ádler Oliveira Silva Neves
n't want the slowdown created by the middleware on every page load, consider removing such middleware and moving its code into the view(s). 2) If you need such data to be displayed in every loaded page in browser, but you can do multiple requests to build a page, consider removing the middlewar

Re: uwsgi stats middleware for Django

2017-12-09 Thread Etienne Robillard
Dear Adler, Thanks again for sharing your code with us. Do you think it would be possible to use asyncio to defer the computation of the active connections from the view or middleware ? Best regards, Etienne Le 2017-12-08 à 11:19, Adler Neves a écrit : forgot mentioning: the number of

Re: uwsgi stats middleware for Django

2017-12-08 Thread Adler Neves
The way you coded that, you are counting how many requests the server has > replied before your request has been processed. > > A bit differently than you, I implemented it as a view (which is not hard > to convert into middleware component) that uses bootstrap, so some small > changes

Re: uwsgi stats middleware for Django

2017-12-08 Thread Adler Neves
Hello again, Etienne! The way you coded that, you are counting how many requests the server has replied before your request has been processed. A bit differently than you, I implemented it as a view (which is not hard to convert into middleware component) that uses bootstrap, so some small

Re: uwsgi stats middleware for Django

2017-12-08 Thread Etienne Robillard
Hi Ádler, Thank you for your reply. Can you please review this code before I commit? """uWSGIController API Version 0.8.3 Middleware for storing uWSGI statistics into the environ object. """ import sys import os import logging import demjson import urll

Re: uwsgi stats middleware for Django

2017-12-07 Thread Ádler Oliveira Silva Neves
cified port and application must be somehow aware of such port number, which has a side-effect of increasing coupling. Sincerely, Adler On 07/12/2017 13:13, Etienne Robillard wrote: > Hi, > > I would like to access the uWSGI stats API from within Django by > creating a custom WSGI middleware.

uwsgi stats middleware for Django

2017-12-07 Thread Etienne Robillard
Hi, I would like to access the uWSGI stats API from within Django by creating a custom WSGI middleware. Could it be possible to compute the number of requests currently being used by uWSGI workers in Python/Django ? Ideally, i could then retrieve the active connections in use in a

Re: Define middleware per app?

2017-08-03 Thread Robert Stepanek
at your’e trying to resolve with middlewares and >>> why you think that you can’t use defaults as is? >>> >>> >> For example: the default middleware stack includes session management, >> CSRF protection and the message middleware. None of this is relevan

Re: Define middleware per app?

2017-08-03 Thread Jani Tiainen
: >> >> Hi, >> >> What is the problem that your’e trying to resolve with middlewares and >> why you think that you can’t use defaults as is? >> >> > For example: the default middleware stack includes session management, > CSRF protection and the messag

Re: Define middleware per app?

2017-08-03 Thread Robert Stepanek
Hi, On Wednesday, August 2, 2017 at 8:31:14 PM UTC+2, Jani Tiainen wrote: > > Hi, > > What is the problem that your’e trying to resolve with middlewares and why > you think that you can’t use defaults as is? > > For example: the default middleware stack includes ses

Re: Define middleware per app?

2017-08-02 Thread Jani Tiainen
API app. For the latter, I do not need the majority of > middleware that is configured by default. Yet, I can't figure out what's the > best approach to use the default middleware stack for the web site app, but > not for the other. > > If I understand correctly, the Djang

Define middleware per app?

2017-08-02 Thread Robert Stepanek
I am new to Django and my project consists of two apps: a typical blog-style web site app and an API app. For the latter, I do not need the majority of middleware that is configured by default. Yet, I can't figure out what's the best approach to use the default middleware stack fo

Django Logger vs Logging Middleware

2017-06-26 Thread Z S
Hi, I want to log every request sent to Django. There are some posts online about logging middleware. The Django documentation talks about logger configuration and it seems that I can set it up to log everything without writing middleware. - Can I log everything without middleware

Re: method's name in MIDDLEWARE

2017-04-15 Thread m712 - Developer
You should take a look at https://docs.djangoproject.com/en/1.11/topics/http/middleware/#process-view It is not a reserved keyword but simply a function that is called by the Django middleware system. On Apr 15, 2017 4:47 PM, shahab emami wrote:hello i want to learn MIDDLEWARE in django  . i

method's name in MIDDLEWARE

2017-04-15 Thread shahab emami
hello i want to learn MIDDLEWARE in django . i created this: class SimpleMiddleware(object): def process_request(self, request): print("") and i added in settings.py. then as you probably know i see "%%" in console with every click. tha

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-08 Thread shahab emami
at you apparently have not completed a good > tutorial to learn how django works and how to use it. > > I would recommend these two tutorials: https://tutorial.djangogirls.org/ > and http://www.marinamele.com/taskbuster-django-tutorial > > said that, this is the relevant documen

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-08 Thread Samuel Brunel
Sorry. I think i'ts in "tokens and SecretBallotMiddleware" Have à look to http://www.pygarden.com/pkg/django-likes, http://stackoverflow.com/questions/1954/django-likes-setup-and-error, http://stackoverflow.com/questions/16179080/django-django-secretballot-middleware Le ven.

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-08 Thread Fabio C. Barrionuevo da Luz
relevant documentation about django Middleware: https://docs.djangoproject.com/en/1.11/topics/http/middleware/ Note: The django Middleware configuration on settings.py was renamed in Django 1.10, from MIDDLEWARE_CLASSES to MIDDLEWARE . Learn more about why this change in: https://github.com/django

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
I knew where middleware is myself. if you read my first post you will see that . my question is: what i have to add to middleware? On Friday, April 7, 2017 at 7:16:36 PM UTC+4:30, shahab emami wrote: > > hello > i have a simple question > please help me if you can > > > i

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread Samuel Brunel
Hi, MIDDLEWARE is in settings.py of your project. Sam Le ven. 7 avr. 2017 23:29, shahab emami a écrit : > tanks > but my problem is: > I don't know where middleware section is. > i looked for middleware section in the app but i couldn't find anything. > that's

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
On Saturday, April 8, 2017 at 1:59:20 AM UTC+4:30, shahab emami wrote: > > tanks > but my problem is: > I don't know where middleware section is. > i looked for middleware section in the app but i couldn't find anything. > that's why i asked that question here

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
nobody can help me in this? what i have to add to middleware class? On Friday, April 7, 2017 at 7:16:36 PM UTC+4:30, shahab emami wrote: > > hello > i have a simple question > please help me if you can > > > i want to install this package on my project: > > https://

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
tanks but my problem is: I don't know where middleware section is. i looked for middleware section in the app but i couldn't find anything. that's why i asked that question here On Friday, April 7, 2017 at 9:10:05 PM UTC+4:30, Daniel Roseman wrote: > > > > On Friday,

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread Daniel Roseman
ion step by step but after adding 'secretballot', > to my installed_apps It says: > > * add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware > section for details) > > > I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after > i

add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
hello i have a simple question please help me if you can i want to install this package on my project: https://pypi.python.org/pypi/django-secretballot/ I am doing the installation step by step but after adding 'secretballot', to my installed_apps It says: * add a secretballot mid

Re: StreamingHttpResponse response length in a stats middleware

2017-01-18 Thread 'Tom Evans' via Django users
On Wed, Jan 18, 2017 at 11:42 AM, Stefano Tranquillini wrote: > Hi there, > > I'm using the StreamingHttpResponse to stream a response, it works great. > Now, I've a middleware that measures the size of req/response that users do. > For normal HttpResponse i use len(respo

StreamingHttpResponse response length in a stats middleware

2017-01-18 Thread Stefano Tranquillini
Hi there, I'm using the StreamingHttpResponse to stream a response, it works great. Now, I've a middleware that measures the size of req/response that users do. For normal HttpResponse i use len(response.content) [i know that it does not give the bytes, but it's pretty

Re: bug of session middleware --- session never expires

2016-12-28 Thread Melvyn Sopacua
On Sunday 25 December 2016 18:42:16 Chaos Wong wrote: > Thanks for the advice. > It's indeed a rude way to force session to expire only depend on the > absolute time. User always encounters session-expired event when > posting something. > I will consider your way 3). But how the django know user

Re: bug of session middleware --- session never expires

2016-12-25 Thread Chaos Wong
Thanks for the advice. It's indeed a rude way to force session to expire only depend on the absolute time. User always encounters session-expired event when posting something. I will consider your way 3). But how the django know user has closed the browser ? 在 2016年12月26日星期一 UTC+8上午5:24:07,Melv

Re: bug of session middleware --- session never expires

2016-12-25 Thread Chaos Wong
ry*(). //line 259 in django.contrib.session.backends.base.py So I think, there seem exist a customized middleware to handle session expire date by call *set_expire*(). But, in my condition,I need the generated time of session_key, which not stored in django session instance, to calculate the h

Re: bug of session middleware --- session never expires

2016-12-25 Thread Melvyn Sopacua
Hi, On Sunday 25 December 2016 11:14:03 ludovic coues wrote: > I believe that is the intended behaviour. > > When I use a banking site for example, I don't want to be disconnected > while doing operations 5 minutes after login in. I want the session > to expire when I stop using it. There is act

Re: bug of session middleware --- session never expires

2016-12-25 Thread ludovic coues
I believe that is the intended behaviour. When I use a banking site for example, I don't want to be disconnected while doing operations 5 minutes after login in. I want the session to expire when I stop using it. Django's session middleware try to solve that use case which is what is

bug of session middleware --- session never expires

2016-12-24 Thread 王超
<https://lh3.googleusercontent.com/-MCd2-kRHmNg/WF44kxNVDNI/AAg/0Xf_TpG1YAUVUzpzdNyb3ZYpxiveGQlfQCLcB/s1600/session_bug.png> django version is 1.10.4 Jsut as the source code shows, session middleware will refresh expires_time with value time.*time*()+max_age, if the the status c

Re: New-style middleware

2016-11-23 Thread Torsten Bronger
Hallöchen! Carl Meyer writes: > [...] > > Yes, I agree with you that for middleware which don't implement > request or response processing (only process_exception, > process_view, or process_template_response), the new style is less > concise, because it requires imp

Re: New-style middleware

2016-11-22 Thread Carl Meyer
Hi Torsten, I worked on the design and implementation of new-style middleware. On 11/22/2016 01:30 PM, Torsten Bronger wrote: > Hallöchen! > > Considering the following old-style middleware class: > > class ExceptionsMiddleware: > def process_exception(self,

New-style middleware

2016-11-22 Thread Torsten Bronger
Hallöchen! Considering the following old-style middleware class: class ExceptionsMiddleware: def process_exception(self, request, exception): ... I convert this to new-style middleware by inserting two methods: class ExceptionsMiddleware: def __init__(self

Re: MIDDLEWARE vs MIDDLEWARE_CLASSES: 'WSGIRequest' object has no attribute 'user'

2016-08-18 Thread Tim Graham
Are you running Django 1.10? It looks like your MIDDLEWARE setting is ignored which suggests you might be using an older version. On Wednesday, August 17, 2016 at 6:43:14 PM UTC-4, Andrew Emory wrote: > > My settings.py file has the default MIDDLEWARE settings generated by > dja

MIDDLEWARE vs MIDDLEWARE_CLASSES: 'WSGIRequest' object has no attribute 'user'

2016-08-17 Thread Andrew Emory
My settings.py file has the default MIDDLEWARE settings generated by django-admin startapp: MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middlewar

django middleware process exception not call

2016-05-18 Thread Luis Zárate
Hi, I was working with middleware that catch exceptions and redirect to other view depending of except type. My idea was raise custom exceptions in several parts of the code and catch in middlewaware with proces exception function, but I have an exception raise in template tag when template is

Re: Why when I call a method within a middleware does not return an HttpResponse?

2016-04-20 Thread 술욱
14:58:03 UTC-3, 술욱 زولوكْ escreveu: >> >> What's the value of request.session['user'] when user is not logged in? >> >> My guess is it's an instance of AnonymousUser. >> >> 2016-04-20 11:43 GMT-03:00 Neto : >> > Hi, >> > >> &g

Re: Why when I call a method within a middleware does not return an HttpResponse?

2016-04-20 Thread Neto
eira, 20 de abril de 2016 14:58:03 UTC-3, 술욱 زولوكْ escreveu: > > What's the value of request.session['user'] when user is not logged in? > > My guess is it's an instance of AnonymousUser. > > 2016-04-20 11:43 GMT-03:00 Neto >: > >

Re: Why when I call a method within a middleware does not return an HttpResponse?

2016-04-20 Thread 술욱
What's the value of request.session['user'] when user is not logged in? My guess is it's an instance of AnonymousUser. 2016-04-20 11:43 GMT-03:00 Neto : > Hi, > > I have a middleware that checks whether the user is logged in. > > class Check(o

Why when I call a method within a middleware does not return an HttpResponse?

2016-04-20 Thread Neto
Hi, I have a middleware that checks whether the user is logged in. class Check(object): """ Check """ @staticmethod def process_request(request): def is_authenticated_user(): try: request.session['

Django middleware cache settings

2016-03-08 Thread nav
Hi I have a need to use memcache on a particular view/controller and wanted to know if the middleware cache settings: 'django.middleware.cache.UpdateCacheMiddleware','django.middleware.common.CommonMiddleware','django.middleware.cache.FetchFromCacheMiddleware',

Re: middleware

2015-08-25 Thread Mayank G
Middleware allows you to process certain pre specified activities like, Logging, User Authentication, Tokenization and filtration of data. Route authentication, Access control list validations. It provides flexibility to invoke appropriate middleware on different routes. These act as glue to

middleware

2015-08-25 Thread Pawanesh Gautam
why middleware is required ?? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, sen

Re: ATOMIC_REQUESTS Middleware inside Transaction

2015-08-20 Thread Tim Graham
I'm not sure what type of reply or answer you are looking for. Overhauling Django middleware as discussed on the developers mailing list might be best in the long run. https://groups.google.com/d/topic/django-developers/uW5Ogio8QBc/discussion On Thursday, August 20, 2015 at 3:54:20 AM

Re: ATOMIC_REQUESTS Middleware inside Transaction

2015-08-20 Thread guettli
nsaction. > > For applications like reversion (app which records the changes of a model) > it is very important, > that the middleware runs inside the same transaction. If storing the > changes > runs in a second transaction, inconsistencies will happen: Model got > updated, &

ATOMIC_REQUESTS Middleware inside Transaction

2015-08-11 Thread guettli
I am not happy that settings.ATOMIC_REQUESTS=True isolates only the view, but not the middlewares in one transaction. For applications like reversion (app which records the changes of a model) it is very important, that the middleware runs inside the same transaction. If storing the changes

Re: Email Middleware

2015-07-09 Thread Stefano Probst
I implement the software now as a custom email backend . My backend manipulate the content of the message and act as wrapper for the real mail backend. -- You received this message because you are subscribed

Email Middleware

2015-07-08 Thread Stefano Probst
Hello, i search for a universal way to modify the content of a mail before send it. Is there a middleware like system for mails? Background: I want to program a system which encrypt outgoing mails via PGP. Best regard Stefano -- You received this message because you are subscribed to the

Re: django custom timezone middleware causing django.contrib.humanize test to fail

2015-03-31 Thread Tim Graham
get all tests to pass with Django 1.5.4 when I have > custom timezone-activating middleware enabled. > > I've posted code here: http://stackoverflow.com/questions/29376612 > > Is there a way to disable the middleware for that specific test? > -- You received this messag

django custom timezone middleware causing django.contrib.humanize test to fail

2015-03-31 Thread Matt Ball
Hi -- I'm unable to get all tests to pass with Django 1.5.4 when I have custom timezone-activating middleware enabled. I've posted code here: http://stackoverflow.com/questions/29376612 Is there a way to disable the middleware for that specific test? -- You received this message b

Re: Running middleware within ATOMIC_REQUESTS transaction

2015-03-12 Thread Marc Aymerich
On Tue, Mar 10, 2015 at 5:38 PM, Marc Aymerich wrote: > > > On Tue, Mar 10, 2015 at 5:15 PM, Marc Aymerich > wrote: > >> >> >> On Tue, Mar 10, 2015 at 5:12 PM, Marc Aymerich >> wrote: >> >>> Hi, >>> I have a middleware that perfor

Re: Running middleware within ATOMIC_REQUESTS transaction

2015-03-10 Thread Marc Aymerich
On Tue, Mar 10, 2015 at 5:15 PM, Marc Aymerich wrote: > > > On Tue, Mar 10, 2015 at 5:12 PM, Marc Aymerich > wrote: > >> Hi, >> I have a middleware that performs some operations at the end of each >> request. >> >> What I have found is that middlew

Re: Running middleware within ATOMIC_REQUESTS transaction

2015-03-10 Thread Marc Aymerich
On Tue, Mar 10, 2015 at 5:12 PM, Marc Aymerich wrote: > Hi, > I have a middleware that performs some operations at the end of each > request. > > What I have found is that middlewares do not run inside the > ATOMIC_REQUESTS transaction. But I want the ATOMIC_REQUESTS transactio

Running middleware within ATOMIC_REQUESTS transaction

2015-03-10 Thread Marc Aymerich
Hi, I have a middleware that performs some operations at the end of each request. What I have found is that middlewares do not run inside the ATOMIC_REQUESTS transaction. But I want the ATOMIC_REQUESTS transaction to rollback if an exception is being raised on my middleware. Any idea on how to

Middleware + Transactions

2015-01-30 Thread Thomas Güttler
as suggested here http://django-reversion.readthedocs.org/en/latest/api.html#revisionmiddleware is quite not feasible for large projects. Especially given that reversion is not the only middleware that needs to be executed within the same transaction as the view function. It would basically mean

Re: Cache middleware problem

2014-12-18 Thread Andreas Kuhne
Add a never cache decorator to the view that does the deleting (and perhaps to the view that lists the items). Then you shouldn't have any problems and you can still use the cache middleware. See https://docs.djangoproject.com/en/1.6/topics/cache/ Regards, Andréas 2014-12-19 5:07 GMT+01

  1   2   3   4   5   6   7   >