Fw: [Zope] problem with the shapelib module.. help

Andreas Jung lists at zopyx.com
Sun Dec 24 01:47:52 EST 2006


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



- --On 23. Dezember 2006 22:27:29 -0800 Allen Huang <swapp0 at yahoo.com> wrote:


>
> 2. but when I save the shapefiles (taiwan1.shp, taiwan1.shx, taiwan1.dbf)
> into zope and call it using dtml it return the same error message.
> import shapelib, dbflib
>         def readshp(filename):
>             shp = shapelib.ShapeFile(filename)
>             return shp.info()
>
>         and in zope
>         <dtml-var expr="readshp(taiwan1.shp)">
>                 or
>         <dtml-var expr="readshp('http://localhost/pytest/taiwan1.shp')">

No idea what shapelib is doing but reading a file from the locale 
filesystem as it seems to work from an external method is *different* from 
a accessing
content that is stored within the ZODB. I really wonder why you think it 
would work the same way? The hierarchical object storage of Zope looks 
similar to a filesystem but it is not a filesystem and the Python APIs for 
accessing filesystems don't apply. We have no idea what the ShapeFile 
constructors expects as data. If it expects a filename of a file within the 
filesystem then you must obtain the content of your data stored within the 
ZODB, create a temporary file and call the constructor as you did within
your external method. Possibly the constructor accepts the data directly
as *string*..in this case this would make things a bit easier. But it is up 
to *you* to check the Shapelib API and take appropriate action.

- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFFjiKYCJIWIbr9KYwRAk0oAKCSyEo5ykswElgi9jFGWf89NthzmwCfRvEM
nSMyeIu/cK7NpecUlof2BR8=
=B0Mw
-----END PGP SIGNATURE-----



More information about the Zope mailing list