codysoyland / django-phased Goto Github PK
View Code? Open in Web Editor NEWSimple two-phase template rendering application useful for caching of authenticated requests
Home Page: http://django-phased.readthedocs.org/en/latest/
License: Other
Simple two-phase template rendering application useful for caching of authenticated requests
Home Page: http://django-phased.readthedocs.org/en/latest/
License: Other
When PhasedRenderMiddleware
is turned on, rendering time grows very fast with size of the content that is outside of phased
block.
For simple page that results in ~100 kB of HTML:
PhasedRenderMiddleware
in MIDDLEWARE_CLASSES
is rendered below 0.1 secondPhasedRenderMiddleware
it takes over 20 seconds on my machine to render.This slowdown is reproducible in many environments:
Steps to reproduce this problem:
example
project from django-phased repositorybase.html
template, outside phased
block{% for _ in ""|ljust:"10000" %} some text {% endfor %}
just after <div id="body">
base.html
template e.g. /blog/
Hey, I am getting error 'WSGIRequest' object has no attribute 'user'
when trying to use django-phased. It happens when I try to refresh a page that was just cached. If I go to another page and then return back to the previous page, it does not happen. I am not exactly sure how to fix this.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8008/messagethreads/
Django Version: 1.6.1
Python Version: 2.7.5
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
'grappelli',
'django.contrib.admin',
'django.contrib.admindocs',
'endless_pagination',
'djangoratings',
'phased',
'imagekit',
'watson',
'auth_ext',
'web')
Installed Middleware:
('phased.middleware.PhasedRenderMiddleware',
'phased.middleware.PatchedVaryUpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'middleware.HttpAuthMiddleware',
'middleware.ProfilerMiddleware',
'middleware.AnonymousUserMiddleware',
'middleware.UserMemberMiddleware',
'middleware.VaryOnAcceptMiddleware',
'watson.middleware.SearchContextMiddleware')
Traceback:
File "/srv/www/envs/cb/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
201. response = middleware_method(request, response)
File "/srv/www/envs/cb/lib/python2.7/site-packages/phased/middleware.py" in process_response
21. response.content = second_pass_render(request, response.content)
File "/srv/www/envs/cb/lib/python2.7/site-packages/phased/utils.py" in second_pass_render
41. restore_csrf_token(request, unpickle_context(bit)))
File "/srv/www/cb/web/context.py" in inbox
51. if not request.is_ajax() and request.user.is_autEnvironment:
Request Method: GET
Request URL: http://127.0.0.1:8008/messagethreads/
Django Version: 1.6.1
Python Version: 2.7.5
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
'grappelli',
'django.contrib.admin',
'django.contrib.admindocs',
'endless_pagination',
'djangoratings',
'phased',
'imagekit',
'watson',
'auth_ext',
'web')
Installed Middleware:
('phased.middleware.PhasedRenderMiddleware',
'phased.middleware.PatchedVaryUpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'middleware.HttpAuthMiddleware',
'middleware.ProfilerMiddleware',
'middleware.AnonymousUserMiddleware',
'middleware.UserMemberMiddleware',
'middleware.VaryOnAcceptMiddleware',
'watson.middleware.SearchContextMiddleware')
Traceback:
File "/srv/www/envs/cb/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
201. response = middleware_method(request, response)
File "/srv/www/envs/cb/lib/python2.7/site-packages/phased/middleware.py" in process_response
21. response.content = second_pass_render(request, response.content)
File "/srv/www/envs/cb/lib/python2.7/site-packages/phased/utils.py" in second_pass_render
41. restore_csrf_token(request, unpickle_context(bit)))
File "/srv/www/cb/web/context.py" in inbox
51. if not request.is_ajax() and request.user.is_authenticated():
Exception Type: AttributeError at /messagethreads/
Exception Value: 'WSGIRequest' object has no attribute 'user'
henticated():
Exception Type: AttributeError at /messagethreads/
Exception Value: 'WSGIRequest' object has no attribute 'user'
Here is the context processor that causes the issue:
def inbox(request):
from models import Message
if not request.is_ajax() and request.user.is_authenticated(): # the error occurs becaue I access request.user here
try: member = request.user.member
except: member = None
return {'inbox_unread_count': Message.get_inbox_unread_count(member)}
else:
return {}
I am trying to apply phased on a snippet where I render flash messages but It doesn't quite work. I get the messages printed on all the pages several times. It's like they are staying in session as not-yet-printed even though they have been already printed by second_pass_renderer.
I got this error when I try to use phased with the comments forms to check if the user is authenticated:
'functools.partial' object has no attribute '__module__'
This is the code on the template:
{% load phased_tags %}
{% phased %}
{% load comments %}
{% if request.user.is_authenticated %}
<a href="/exit/">Exit</a>
{% render_comment_form for enq %}
{% else %}
<a href="/login/">login</a>
{% endif %}
{% endphased %}
Is there something wrong with the code?
Thanks!
Probably a known problem, but I couldn't see it in the docs anywhere.
If you try and use {% phased %} and the trans tag you get a TemplateSyntaxError: Invalid block tag: 'trans' error message.
Is there away around this?
Hi,
This repository seems to lack maintenance, I propose myself as a new maintainer.
Could you give me the right to push in your repository or just transfer it on my account in github?
Thank you
Getting the following error. Just trying to use {% phased %}{% endphased %} tags.
I get the error only when PHASED_KEEP_CONTEXT = True
PicklingError at /
Can't pickle <type 'function'>: attribute lookup builtin.function failed
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.4.3
Exception Type: PicklingError
Exception Value:
Can't pickle <type 'function'>: attribute lookup builtin.function failed
Exception Location: /home/harshil/workspace/seedinvest/local/lib/python2.7/site-packages/phased/utils.py in pickle_context, line 152
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.