Thursday, March 18, 2010

Re: Multiple host-based settings file

Hi,
Thanks for your replies.
What I finally decided on was:

Step 1: Create a middleware to make the current request accessible
everywhere-

from threading import local
CURRENT_REQUEST=local()
class CurrentRequestMiddleware(object):
"""
"CurrentRequestMiddleware" :
"""
def process_request(self, request):
CURRENT_REQUEST.request=request

Step 2: Add a __getattr__ method to django.conf.LazySettings file to
return host specific setting if avaiable

from django.middleware.CurrentRequestMiddleware import CURRENT_REQUEST

def __getattr__(self, name):
try:

specific_setting=get_host_specific_setting(CURRENT_REQUEST.request.getHostname())
if specific_setting:
return specific_setting
except:
pass
return super(LazySettings,self).__getattr__(name)

Step 3:
Create a normal django appto store custom settings in the
database and implement the get_host_specific_setting used above

So far it is running well enough on dev. Any problems which i cannot
foresse?

Thanks,
Shitiz

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Authentication system : should I use contrib.auth or reinvent the wheel?

> - in contrib.auth.views, the login sends no error for authentication
> failures, and sends the page again silently.

My mistake: the form.errors contains the authentication error.

On Mar 19, 1:46 pm, Peyman <peyman.goh...@gmail.com> wrote:
> Hi all,
>
>   I need an authentication system for my website; quite a common need
> today, isn't it?
>   I have decided to figure out if I can use django.contrib.auth. I
> have the following problems :
>
> 1. start a new project, and just do the minimum:
> *in settings:
>  - a database
>  - a template path
>  - the django.contrib.admin app
> *then syncdb
> *in urls: uncomment the admin urls
> *add in your template folder, the file requested by the view
> password_change in contrib.auth.views :
>  - registration/password_change_form.html
>  - this file contains a simple text
>
> Problem : trying to access http://<your.site>/admin/password_change
> will render -- after login -- your template in registration/
> password_change_form.html instead of the admin one. I can't find out
> why.
>
> 2. strange things in code :
>  - in contrib.auth there is a UserCreationForm provided, but there
> seems to be no view for it or for any signup page.
>  - in contrib.auth.views, the login sends no error for authentication
> failures, and sends the page again silently.
>
> I hope I am wrong in all this, due to the fact that I am a new django
> user. Your help is welcome.
> Also : instead of contrib.auth, what is generally used for
> authenticating users?
>
> Thanks
> -- Peyman

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: content template loads at bottom of base template instead of top

OK, dare I state the obvious, I am pretty green at this. Thanks for
helping out. I'll try and be more specific:

My site is sitting at http://staging.bluecaravan.net . The 'glitch'
happens fairly frequently (over 50%) and on random pages through the
site.

I'll paste my base template, and a content template and a view at
dpaste:

http://dpaste.com/173541/ view

http://dpaste.com/173543/ base template

http://dpaste.com/173544/ inner content template

My webhost helpdesk has suggested my style sheet isn't loading fast
enough. Do you think that might be the problem?

I'll get back to yuse with details of the frobnulator module. I didn't
hear it whizz, but I could've missed it :-\

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Authentication system : should I use contrib.auth or reinvent the wheel?

Hi all,

I need an authentication system for my website; quite a common need
today, isn't it?
I have decided to figure out if I can use django.contrib.auth. I
have the following problems :

1. start a new project, and just do the minimum:
*in settings:
- a database
- a template path
- the django.contrib.admin app
*then syncdb
*in urls: uncomment the admin urls
*add in your template folder, the file requested by the view
password_change in contrib.auth.views :
- registration/password_change_form.html
- this file contains a simple text

Problem : trying to access http://<your.site>/admin/password_change
will render -- after login -- your template in registration/
password_change_form.html instead of the admin one. I can't find out
why.

2. strange things in code :
- in contrib.auth there is a UserCreationForm provided, but there
seems to be no view for it or for any signup page.
- in contrib.auth.views, the login sends no error for authentication
failures, and sends the page again silently.

I hope I am wrong in all this, due to the fact that I am a new django
user. Your help is welcome.
Also : instead of contrib.auth, what is generally used for
authenticating users?

Thanks
-- Peyman

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: models.TextField --> \r\n in DB

Hi Thomas,

Django's normalize_newlines function should do the trick. You can import it from django.utils.text. See this page for an example:

Best,
Paulo

On Thu, Mar 18, 2010 at 4:27 PM, Thomas Guettler <hv@tbz-pariv.de> wrote:
>
> Hi,
>
> I just discovered that I have a random mix auf rows
> some with \r\n and some with only \n.
>
> I guess it depends on using a windows or linux browser
> to access the app.
>
> I use models.TextField (with django 1.0).
>
> Has someone seen this, too?
>
> What do you do?
>
>  Thomas
>
> --
> Thomas Guettler, http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
>
> --
> 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 django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: ManagementForm validation error in unit test

Mystery solved. Thanks for your help, and sorry for the waste of time, but the problem was that I missed a previous form submission in the same test function, that was used just to test validation. I hadn't added the ManagementForm variables there, so that was the problem.

Best regards,
Paulo

On Thu, Mar 18, 2010 at 5:18 PM, raj <rajeeshrnair@gmail.com> wrote:

> This works, but if I leave out the prefix in the last command then the same
> ValidationError is raised.

You've almost worked it out yourself. This error usually occurs when
the given prefix does not match with what django expected. When you
don't provide any prefix argument on generating formset, django
expects the default prefix. Try ImageFormset.get_default_prefix() to
get that value and use it in your data dictionary



Rajeesh.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.