Arachnid / bloggart

A blog application for App Engine
http://bloggart-demo.appspot.com/
287 stars 78 forks source link

Please add an __init__.py file to the project root #41

Open attilaolah opened 14 years ago

attilaolah commented 14 years ago

Hi,

Please consider adding an empty init.py file to the project root. Here's why.

I'm using bloggart under a custom prefix ('/blog/'), with a buildout-based application. The easiest way for me to set it up is to use http://github.com/zerok/zerokspot.gitrecipe/ to grab the latest revision from github.

I don't change anything to the code, I just have a custom dict with my own settings and scripts that look like this (pseudocode):

# my_custom_static.py:
from somewhere import my_custom_settings
# mangle sys.path to insert bloggart's directory
# (which is actually a symlink as I use rod.recipe.appengine
# to put things together for me)
import config # this is bloggart config
[setattr(config, *item) for item in my_custom_settings.iteritems()]

# Then do the rest
from static import main # this is your static.py
if __name__ == '__main__':
    main()

As you can see, it is quite frustrating and also it's hard not to make filename clashes. If you'd add an init.py to the root, that probably wouldn't change anything for your code if run stand-alone, but my code would be much cleaner as I could use your code like a package, without manging my sys.path.

Arachnid commented 14 years ago

I'd be surprised if this is sufficient - I believe bloggart uses absolute imports in places. If you want to try this, and it works, however, send me a pull request and I'll approve it!