Wednesday, June 29, 2011

Re: Global generic files? Best practice(s)?

If you're using it for multiple apps, but just one project and the apps are project-specific, then this code could very well lie in your project's utils.py or any other module.

If you're writing code that's meant to be reused by third-parties, then the picture is rather different. I recently had a similar problem and I thought about writing a try/except block that tries to imports your global module with the necessary utilities and if it fails, it defines the functions itself. This way you allow for an easy global override of the needed utilities in case your needs vary.

I'm not sure this is the standard/best practice, but I believe I've seen similar bits of code in django core. A more experienced developer's point of view is most welcome here!


Sincerely,
André Terra

On Tue, Jun 28, 2011 at 5:39 PM, Micky Hulse <rgmicky@gmail.com> wrote:
Hello,

I was going to start a "global" app for a generic "helpers.py" file; I
plan on using this code in multiple apps.

Question: Is creating a generic app a standard approach to storing
"global" code?

...

If the answer to the above question is "yes":

What's your preferred approach to handling generic/global code?

When using a "global" app how do you package apps that have files that
are not inside app structure? Would you change re-factor/re-arrange
your code/files or would you include the "global" app in your
package/packaging?

TIA!

Cheers,
Micky

--
Micky Hulse
Web Content Editor
The Register-Guard
3500 Chad Drive
Eugene, OR 97408
Phone: (541) 338-2621
Fax: (541) 683-7631
Web: <http://www.registerguard.com>

--
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.

No comments:

Post a Comment