Re: [Zope3-dev] xml import / export in z2 z3

2005-12-12 Thread Kapil Thangavelu
fwiw, we're working on doing this in plone land, utilizing the non  
standard, fast, incremental, validating XmlReader interface from libxml  
and pluggable namespace handlers. the xmlreader iface is very SAX like.


http://svn.plone.org/view/archetypes/Marshall/branches/k_vertigo-pluggable-ns/

-k


On Wed, 07 Dec 2005 06:33:46 -0800, Jean-Marc Orliaguet  
[EMAIL PROTECTED] wrote:



Martijn Faassen wrote:


Andreas Jung wrote:

I'm about to write an xml importer for importing simple data  
(properties,
dictionaries). Exporting is easy, importing is trickier because a  
parser

is required.

Is there any prefered framework for doing such things in zope3  
(zope2)?




Sax or DOM...it depends on the usecase and the algorithmic approach  
you take. Sax is fast but you have to build your own datastructures,  
DOM is slow, takes a lot of memory but it gives you a tree to perform  
any fancy operation on it..



DOM is also not particularly Pythonic (neither is SAX, but it is  
relatively simple at least). You could also look into ElementTree (or  
lxml, which implements that API too). ElementTree (though not yet lxml)  
also introduces iterparse, which is a kind of streaming version of the  
ElementTree API.


ElementTree's API is a much nicer way to work with XML from Python than  
DOM. Also it's more lightweight than even MiniDOM.


Regards,

Martijn



thanks for the info Martijn, I'm going to look at it.

I've done some work with ElementTree for CPSIO, and I haven't found it  
very easy to use because of all the extra namespace URI, and xpath stuff  
used for the tree navigation (xpath_findall, ..) which seem to get in  
the way. Also it could be that I find the DOM approach easier since I'm  
used to it in javascript already.


the question is also about being able to reuse parts of the  
export/import code of CMFSetup / GenericSetup and possibly simplify the  
zope2 - zope3 migration of existing applications.


best
/JM

___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] xml import / export in z2 z3

2005-12-08 Thread Joseph Method
There's also Amara, which is designed to be Pythonic:

http://uche.ogbuji.net/uche.ogbuji.net/tech/4suite/amara/

On 12/7/05, Jean-Marc Orliaguet [EMAIL PROTECTED] wrote:
 Martijn Faassen wrote:

  Andreas Jung wrote:
 
  I'm about to write an xml importer for importing simple data
  (properties,
  dictionaries). Exporting is easy, importing is trickier because a
  parser
  is required.
 
  Is there any prefered framework for doing such things in zope3 (zope2)?
 
 
  Sax or DOM...it depends on the usecase and the algorithmic approach
  you take. Sax is fast but you have to build your own datastructures,
  DOM is slow, takes a lot of memory but it gives you a tree to perform
  any fancy operation on it..
 
 
  DOM is also not particularly Pythonic (neither is SAX, but it is
  relatively simple at least). You could also look into ElementTree (or
  lxml, which implements that API too). ElementTree (though not yet
  lxml) also introduces iterparse, which is a kind of streaming version
  of the ElementTree API.
 
  ElementTree's API is a much nicer way to work with XML from Python
  than DOM. Also it's more lightweight than even MiniDOM.
 
  Regards,
 
  Martijn


 thanks for the info Martijn, I'm going to look at it.

 I've done some work with ElementTree for CPSIO, and I haven't found it
 very easy to use because of all the extra namespace URI, and xpath stuff
 used for the tree navigation (xpath_findall, ..) which seem to get in
 the way. Also it could be that I find the DOM approach easier since I'm
 used to it in javascript already.

 the question is also about being able to reuse parts of the
 export/import code of CMFSetup / GenericSetup and possibly simplify the
 zope2 - zope3 migration of existing applications.

 best
 /JM


 ___
 Zope3-dev mailing list
 Zope3-dev@zope.org
 Unsub: http://mail.zope.org/mailman/options/zope3-dev/tristil%40gmail.com




--
-J. Method


--
-J. Method
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] xml import / export in z2 z3

2005-12-07 Thread Martijn Faassen

Jean-Marc Orliaguet wrote:
I'm about to write an xml importer for importing simple data 
(properties, dictionaries). Exporting is easy, importing is trickier 
because a parser is required.


Is there any prefered framework for doing such things in zope3 (zope2)?

CMFSetup uses sax, GenericSetup uses sax too. ZCML relies on sax... Does 
it mean that writing a sax parser is the way to go, (again this is very 
simple data) or is there any other library recommended in the context of 
zope?


Silva uses SAX too. SAX is comparatively hard to use though.

Regards,

Martijn
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] xml import / export in z2 z3

2005-12-07 Thread Jean-Marc Orliaguet

Martijn Faassen wrote:


Andreas Jung wrote:

I'm about to write an xml importer for importing simple data 
(properties,
dictionaries). Exporting is easy, importing is trickier because a 
parser

is required.

Is there any prefered framework for doing such things in zope3 (zope2)?




Sax or DOM...it depends on the usecase and the algorithmic approach 
you take. Sax is fast but you have to build your own datastructures, 
DOM is slow, takes a lot of memory but it gives you a tree to perform 
any fancy operation on it..



DOM is also not particularly Pythonic (neither is SAX, but it is 
relatively simple at least). You could also look into ElementTree (or 
lxml, which implements that API too). ElementTree (though not yet 
lxml) also introduces iterparse, which is a kind of streaming version 
of the ElementTree API.


ElementTree's API is a much nicer way to work with XML from Python 
than DOM. Also it's more lightweight than even MiniDOM.


Regards,

Martijn



thanks for the info Martijn, I'm going to look at it.

I've done some work with ElementTree for CPSIO, and I haven't found it 
very easy to use because of all the extra namespace URI, and xpath stuff 
used for the tree navigation (xpath_findall, ..) which seem to get in 
the way. Also it could be that I find the DOM approach easier since I'm 
used to it in javascript already.


the question is also about being able to reuse parts of the 
export/import code of CMFSetup / GenericSetup and possibly simplify the 
zope2 - zope3 migration of existing applications.


best
/JM


___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



[Zope3-dev] xml import / export in z2 z3

2005-12-06 Thread Jean-Marc Orliaguet

Hi!

I'm about to write an xml importer for importing simple data 
(properties, dictionaries). Exporting is easy, importing is trickier 
because a parser is required.


Is there any prefered framework for doing such things in zope3 (zope2)?

CMFSetup uses sax, GenericSetup uses sax too. ZCML relies on sax... Does 
it mean that writing a sax parser is the way to go, (again this is very 
simple data) or is there any other library recommended in the context of 
zope?


I have no problem switching between setup applications, but writing a 
parser is a bit of pain, so I'd like not to have to redo that part too 
often.


Best
/JM
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] xml import / export in z2 z3

2005-12-06 Thread Jean-Marc Orliaguet

Andreas Jung wrote:




--On 6. Dezember 2005 16:46:02 +0100 Jean-Marc Orliaguet 
[EMAIL PROTECTED] wrote:



Hi!

I'm about to write an xml importer for importing simple data 
(properties,

dictionaries). Exporting is easy, importing is trickier because a parser
is required.

Is there any prefered framework for doing such things in zope3 (zope2)?



Sax or DOM...it depends on the usecase and the algorithmic approach 
you take. Sax is fast but you have to build your own datastructures, 
DOM is slow, takes a lot of memory but it gives you a tree to perform 
any fancy operation on it..


-aj



now I've tried both, DOM (minidom) works the best by far for small 
objects (that's by the way used in CMFSetup too). Updating global 
datastructures from events with Sax is a pain...


thanks
/JM
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com