Am 27.05.2010 20:13, schrieb Barum:
> My background in web development consist only of PHP and I recently
> started playing around different web frameworks in Python. I am having
> a minor problem, but it feels like I am missing something.
> 
> I would like to build pluggable applications that may depend on
> another. For example, blog app and forum app depend on auth app which
> takes care of the user authentication. Ideally, I would like to work
> with the following directory structure:
> 
> blog/
>    blog.py
>    model.py
> forum/
>    forum.py
> auth/
>    auth.py
> 
> In blog.py, I want to do 'from .. import auth' but it seems that this
> is possible only in a package installed in site-packages. I guess I
> can add my work directory to sys.path but that does not seem to be a
> clean solution.
> 
> I would love to hear some inputs on how to manage different components
> of a website.
> 

You need a __init__.py in blog, forum, and auth ... and in the parent
directory ...

so:
/
  __init__.py
  blog/
     __init__.py
     blog.py
     model.py
  forum/
     __init__.py
     forum.py
  auth/
     __init__.py
     auth.py

Oh -- and this only works if you import blog from somewhere else ... it
will not work if "blog.py" is the "main application" file.

- René

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to