Re: problem with login_required decorator in python2.3

2006-03-17 Thread Kenneth Gonsalves

On Friday 17 Mar 2006 6:20 pm, Les Smithson wrote:
> Write you own login_required and use that as a decorator:
>
> from django.views.decorators.auth import user_passes_test,
> login_required
> mylogin_required = user_passes_test(lambda u: not
> u.is_anonymous(), login_url="/my/login/")

simpler to just use user_passes_test

-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: problem with login_required decorator in python2.3

2006-03-17 Thread Kenneth Gonsalves

On Friday 17 Mar 2006 6:20 pm, Les Smithson wrote:
> Write you own login_required and use that as a decorator:
>
> from django.views.decorators.auth import user_passes_test,
> login_required
> mylogin_required = user_passes_test(lambda u: not
> u.is_anonymous(), login_url="/my/login/")
>
> @mylogin_required
> def blagh(request):

neat

-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: problem with login_required decorator in python2.3

2006-03-17 Thread Kenneth Gonsalves

On Friday 17 Mar 2006 5:43 pm, Amit Upadhyay wrote:
> Monkey patching:
>
> If you find
> login_requiredication/#the-login-required-decorator>decorator enough for your
> needs, but do not like the /accounts/login/ url, you can edit
> django/views/auth/login.py and set them what you want. They
> should make it configurable through setting.py

dont want to monkey patch - i have 9 sites running on the same 
django and am using svn

-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: problem with login_required decorator in python2.3

2006-03-17 Thread oggie rob

With trunk, I dealt with this by changing admin/base_site.html
Just overide the userlinks block

I found the relative links annoyingly limiting so I changed them to
absolutes (I mean absolute according to the base directory - I didn't
have any server info in them) by way of a decorator & the settings
file.

in templates/admin/base_site.html:
{% block userlinks %}

{% trans 'Change password'
%} / {% trans 'Log out' %}

{% endblock %}

In my models/__init__.py file (note that this is not python 2.3
friendly):
@defaulttags.register.simple_tag
def baseurl():
if hasattr(settings, 'BASE_URL_PREFIX'):
return '/' + settings.BASE_URL_PREFIX
return ''

In my settings.py file:
# web server prefix
BASE_URL_PREFIX = 'blogs'

hth,
-rob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: problem with login_required decorator in python2.3

2006-03-17 Thread Les Smithson




On Fri, 2006-03-17 at 17:05 +0530, Kenneth Gonsalves wrote:


hi,
my site is on "/web/', so for example, my home page is:
http://mysite.com/web/home/ and admin is in:
http://mysite.com/web/admin/

but using login_required decorator, the thing is directed to:
http://mysite.com/accounts/login/ when i want it to go to 
http://mysite.com/web/login/

How to solve this?



Write you own login_required and use that as a decorator:

from django.views.decorators.auth import user_passes_test, login_required
mylogin_required = user_passes_test(lambda u: not u.is_anonymous(), login_url="/my/login/")

@mylogin_required
def blagh(request):
   ...

I haven't figured out how to override the template path 'registration/login' yet.




-- 
Les Smithson <[EMAIL PROTECTED]>
Open Network Solutions Ltd







signature.asc
Description: This is a digitally signed message part


Re: problem with login_required decorator in python2.3

2006-03-17 Thread Amit Upadhyay
On 3/17/06, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
but using login_required decorator, the thing is directed to:http://mysite.com/accounts/login/ when i want it to go tohttp://mysite.com/web/login/
How to solve this?Monkey patching: If you find login_required
decorator enough for your needs, but do not like the /accounts/login/
url, you can edit django/views/auth/login.py and set them what you
want. They should make it configurable through setting.py Django Tips-- Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay+91-9867-359-701
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django users" group.  To post to this group, send email to django-users@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



problem with login_required decorator in python2.3

2006-03-17 Thread Kenneth Gonsalves

hi,
my site is on "/web/', so for example, my home page is:
http://mysite.com/web/home/ and admin is in:
http://mysite.com/web/admin/

but using login_required decorator, the thing is directed to:
http://mysite.com/accounts/login/ when i want it to go to 
http://mysite.com/web/login/

How to solve this?
-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---