Re: is there a simpler way to do 3rd party app settings?

2007-02-27 Thread Afternoon

People should always do the INSTALLED_APPS edit themselves, I have
apps installed I'm not using, not least all the contrib apps!

For everything else I use something like

setting = getattr(settings, "MY_NEW_SETTING", default)

or

try:
setting = settings.MY_NEW_SETTING
except AttributeError:
# do something sensible, like return or nothing actually,
# because sometimes the AttributeError getting raised to the
# browser is the best way to hint that the setting is required

Ben


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: is there a simpler way to do 3rd party app settings?

2007-02-26 Thread Malcolm Tredinnick

On Mon, 2007-02-26 at 01:58 -0800, idadesub wrote:
> Hello,
> 
> Looking at how one can make apps, it seems a little ugly having to
> have an end user of an app manually add all the default settings for
> an app to their settings.py file. I didn't miss some easy way on how
> to do this, did I? The options I can think of don't really work out
> that well.

No you didn't miss an easy way. And the reason is because there are lots
of corner-cases, so it's tricky. But don't let that stop you from coming
up with a good solution to the problem and convincing us, because this
would be a good thing to solve, I suspect.

[...]
> Has anyone come up with a good solution to this?

The last time this came up was around the end of OSCON last year, I
think (I remember replying to emails on it whilst sitting in Portland
airport). So search the django-users archives from around the end of
July 2006 for some other ideas. However, my vague recollection of what
we have thought about...

I think you are always going to have to add something to settings.py to
say you are adding a new app. Auto-discovery is a bit risky in many
cases and won't work in one common case where your settings file is
nowhere near your project and app code. There was discussion in the past
of whether we should then look for /settings.py for
app-specific settings, which leads to discussions about namespacing: you
don't want your settings to stomp on somebody else's, but sometimes you
do want to override. No clear conclusions were reached, but editing your
particular settings.py file for the site is always going to be possible,
so this wasn't a complete show-stopper.

Things to work out when you are trying to think about this:

- do app-specific settings.py files override things in the
site's settings.py (if you go that route)?

- how to avoid inadvertent clashes with other applications (if
you don't go down the app-specific file route)?

- do we allow things like app-specific
TEMPLATE_CONTEXT_PROCESSOR settings (I was against this last
time, but there was an argument made in favour of it)?

Regards,
Malcolm


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---