Re: [Zope-dev] Organizing modules in a python product

2001-03-18 Thread Itai Tavor

Thanks, Dieter. You're right, I definitely wouldn't want to use this 
solution. I was hoping for something that can be done inside the 
product :-(


Dieter Maurer wrote:

Itai Tavor writes:
   ... abbreviated references to sibling subproducts ...
   Is there any way to set this up so imports like 'import Utils' and
   'import Module2' would work in Module1? As a bonus, can I also get
   __init__.py files in each module directory to be executed?
You can manipulate (extend) "sys.path" in your (top level)
"__init__.py" file. Python starts its package/module lookup
from the elements in "sys.path".

However, I doubt very much, that you should do this!
You will lose the namespace isolation provided by packages.



Dieter

-- 
--
Itai Tavor  -- "Je sautille, donc je suis."--
[EMAIL PROTECTED]--   - Kermit the Frog --
-- "What he needs now is understanding... and a confederate victory" --
-- Dr. Jacobi, Twin Peaks --


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Organizing modules in a python product

2001-03-16 Thread Dieter Maurer

Itai Tavor writes:
  ... abbreviated references to sibling subproducts ...
  Is there any way to set this up so imports like 'import Utils' and 
  'import Module2' would work in Module1? As a bonus, can I also get 
  __init__.py files in each module directory to be executed?
You can manipulate (extend) "sys.path" in your (top level)
"__init__.py" file. Python starts its package/module lookup
from the elements in "sys.path".

However, I doubt very much, that you should do this!
You will lose the namespace isolation provided by packages.



Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] Organizing modules in a python product

2001-03-15 Thread Itai Tavor

Hi,

I'm writing a python product containing around 40-50 modules, each 
one with some dtml files. At the moment I got all the modules .py 
files in the product directory, and a www directory with 
subdirectories for each module.

Products
   | -- MyProduct
   |-- Module1.py
   |-- Module2.py
   | www
   |-- Module1
  |-- addModuleForm.dtml
   |-- Module2
  |-- index.dtml
   |-- Utils.py

I want to change this to a layout where all the files for a module 
are grouped together:

Products
   |-- MyProduct
  |-- Module1
 |-- Module1.py
 |-- www
|-- addModuleForm.dtml
  |-- Module2
 |-- Module2.py
 |-- www
|-- index.dtml
|-- Utils.py

But I'm finding this very hard to work with. In Module1, importing 
from Utils require doing 'from Products.MyProduct.Utils', and 
importing from another Module2 requires 'from 
Products.MyProduct.Module2.Module2'.

Is there any way to set this up so imports like 'import Utils' and 
'import Module2' would work in Module1? As a bonus, can I also get 
__init__.py files in each module directory to be executed?

TIA

Itai
--
Itai Tavor  -- "Je sautille, donc je suis."--
[EMAIL PROTECTED]--   - Kermit the Frog --
-- --
-- "Every day, once a day, give yourself a present"  - Dale Cooper --


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )