[Zope-dev] Zope 2: circular import

Tres Seaver tseaver at palladion.com
Sun Dec 27 13:06:03 EST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

yuppie wrote:
> Hi!
> 
> 
> I stumbled over a circular import in Zope 2.
> 
> 
> in DocumentTemplate.DT_Util:
> from ZPublisher.TaintedString import TaintedString
> 
> this triggers ZPublisher.BaseRequest with:
> from AccessControl.ZopeSecurityPolicy import getRoles
> 
> this triggers AccessControl.DTML with:
> from DocumentTemplate import DT_Util
> 
> 
> With try/except imports and the right import order this works, but it 
> would be better to break up that circle.
> 
> At first glance the solution is simple: TaintedString doesn't have any 
> dependencies and is used by DocumentTemplate and ZPublisher. So it 
> should be moved to a place where both modules can use it without 
> triggering countless imports.
> 
> But where would be a good place for TaintedString? It is too small to 
> create a package just for that. In which existing package would it fit?
> 
> Or should we just add a copy of TaintedString to DocumentTemplate?

Put it in Shared.DC.Scripting?  ZPT and DTML already depend on it, I
think (oops, no, ZPT and PythonScript, but not DTML).  Or just put it in
a module / package in the Zope2 distribution's 'src' directory.

While we're at it, the circular import between ZServer and ZPublisher is
insane, too.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAks3ogsACgkQ+gerLs4ltQ7n2ACfS2eKzoshRz2KuyJIsi+9WIHO
ZLcAoIfIINZDKtedf3LWfyGYoFT9iPHS
=0owd
-----END PGP SIGNATURE-----



More information about the Zope-Dev mailing list