Archive for February, 2006
ElementTree, serialization and namespace prefixes
The way ElementTree
outputs namespaces in serialized output can be a problem with some
applications.
Here is an example of such an ouput :
>>> import cElementTree as etree >>> stream = """<?xml version="1.0" encoding="UTF-8" ?> ... <doc xmlns="http://bar" ... xmlns:foo="http://foo/"> ... <foo:sub/> ... </doc>"" >>> >>> doc = etree.XML(stream) >>> print etree.tostring(doc, encoding="UTF-8") <?xml version="1.0" encoding="UTF-8" ?> <ns0:doc xmlns:ns0="http://bar"> <ns1:sub xmlns:ns1="http://foo" /> </ns0:doc> >>>
We can see that the declared namespaces are now given an alias and all
prefixes are now changed using those defined aliases. This is absolutley
correct in a XML point of view but you can be in trouble sometimes with some
applications for which you are outputing XML from elementtree based Python programs because they do not support
this properly on their side.
Here is a workaround I found but I don’t know if others exist :
>>> import cElementTree >>> import elementtree.ElementTree >>> >>> … Read more
Choosing a Javascript library for Zope
Choosing a Javascript library for Zope
Background
What’s AJAX ?
(If you know it, you should skip this section)
Wikipedia says:
Asynchronous JavaScript and XML, or Ajax, is a web development technique for creating interactive web applications using a combination of: - XHTML (or HTML) and CSS for marking up and styling information - The Document Object Model manipulated through JavaScript to dynamically display and interact with the information presented - The XMLHttpRequest object to exchange data asynchronously with the web server. (XML is commonly used, although any format will work, including preformatted HTML, plain text, JSON and even EBML) Like DHTML, LAMP, or SPA, Ajax is not a technology in itself, but a term that refers to the use of a group of technologies together. In fact, derivative/composite technologies based substantially upon Ajax, such as AFLAX, are already appearing.
(full definition here: What’s AJAX ?)
In other words,
CPS Ajaxification, round #1
In my
last blurg I said I would select some toolkit out there to compare the
result, but after some mails exchanged on Z3 mailing list (
Ajax in Zope 3 Thread), I agreed with what Benji York and Gary Poster said
in this subject:
“I’m very interested in coming up with a one or more relatively simple
server-side proposals to make Ajax stuff easier, but I think the Ajax
stuff (and even the whole JavaScript world) is too immature to settle on
one client-side implementation. Therefore we should concentrate on doing
things that help most or all of the JS toolkits be more usable with Z3.”
So I have started the work over CPS with Scriptaculous, focusing on
uses cases and when doable, on the server-side infrastructure.
CPS Use case #1: CPSDocument AJAX form controller with graceful
degradation
The first use case in CPS is to embed existing
Guido and Webframeworks
Guido van Rossum has started to
look for web frameworks. Now, he doesn't seem to enthusiastic about
using Zope. And at first it looks like he is making the right choice,
because his stated requirement list is too small:
- Independence from web server technology.
- Templating with reuse.
- Cookie handling.
- Query parsing.
- URL dispatch.
Note especially the lack of any kind of data storage, authentication/access
control, forms and session handling. Well, with these requirements, he
shouldn't use Zope, that's for sure. But does he really not want any
storage, or access control?
Wel….in his second
post he extends the requirements quite lot, and suddenly it seems like
persistence, acces control and session is in the game again:
"Maybe we need more standardization efforts like WSGI, that let you plug
in different animals, or roll your own, for various pieces of useful web
functionality: for example URL dispatch, templates, persistence,… Read more
Reminder : OOo Developpers Article Contest
The first
session of the Developpers Article Contest is running and will end at
the end of the month.
As announced, this contest is to generate new documentation to developpers
and everybody can participate. Developpers and technical writers are
welcomed to propose articles. The subject has to cover a technical aspect of
OOo such as building, patching, addon, extensions or OOo scripting
aso.
Submissions have to be sent as attachments in the OASIS OpenDocument file
format to the mailing list contest@development.openoffice.org
The
contest rules can be found on the OOoWiki. Each
month, an article will be elected and the winner author will earn 750 euros.
He will also be member of the comitee for three months if he wants The
remaining articles will stay in the contest for the next month so you have
many chances to win
So, write your articles and submit them. We are all waiting … Read more
OOoCon2006 : Results … After Koper, let’s go to …
Lyon has been choosen by votes
The official annoucement by Jacqueline, marketing lead
http://www.openoffice.org/servlets/ReadMsg?list=announce&msgNo=272
After the good work of Cédric at INSA, lets help him now organizing this
event.
All the energies are welcomed to make this event as successfull as the
previous years
You”ll surely be called for help – Stay tuned !!
(Post originally written by Laurent Godard on the old Nuxeo blogs.)
Apogée project website goes live !
We just put online the community portal for the Apogée project : apogee.nuxeo.org.
It includes a public website and a collaboration workspaces where all
people interested in the project can collaborate (document sharing and
reviewing with versionning, openoffice and docbook support, etc.).
We also published some design
documents of the project (on the XForms engine and global architecture).
This site is really expected to live and be the center of the community.
We invite all people interested to join the site and start working on
documents (the mailing-list is also available for discussions).
I hope to see you there !
(Post originally written by Eric Barroca on the old Nuxeo blogs.)
A few rules to keep in mind when using Ajax
In this entry, I try to sum up some rules that should be looked over when
adding AJAX features in a CMS.
keep accessibility
A CMS is used by a wide variety of people and WAI rules should be kept in
mind. All functions and screens should be usable even though javascript is
not enabled.
This means that AJAX features have to be implemented with methods like
graceful degradation to avoid the CMS to be dependent on Javascript
features.
Most of the time, this is quite easy to implement a Javascript enhanced
version over a regular version, but sometimes two version has to be
developed in parallel, like gmail for example does.
There are few exceptions for this rule:
- it’s ok to develop managment screens or backoffice screens in
javascript
- same things for some products like webmails, calendars: people that
really need accessibility for these very specific products will use
CPS Ajaxification, round #6 a dynamic tree and an event oserver
Features
The treeview that we wanted is pretty similar to what Zope 3 has
(xmltree), except that it one is implemented with scriptaculous. The principles are quite simple: branches of the tree are asynchronously loaded
through Javascript whenever we need it. Scriptaculous provides the nice fade-in effect, which make the whole thing looks good.
Now the biggest deal was to be able to hook the treeview with what happens
in the center of the page.
Since some drag’and’drop features were previously added, the tree needs
to be refreshed whenever a drop which changes the structure of the portal is made. In our case, it happens when folders are reordered or a folder is dropped
over the treeview. A event mechanism has been created, in order to be able to refresh the treeview whenever a ‘drop event’ happens.
See ‘implementation details’ section for some details.
Screencast
(if you read this entry … Read more
Looking for fast and memory friendly Python XML processing ?
? Are you tired of running out of RAM ? You got memory leaks all around
?
I've been in this situation until last week for one year.
I spent the last week rewriting a customer application written in cDomlette using cElementTree (note when I
wrote it at this time cELementTree didn't
exist).
My cDomlette experience has been a real pain last
year with this project for the reasons I described above.
Don't get me wrong about cDomlette. This is a library really
well documented and much more better than the available DOM libraries in the standard Python
distribution but you can't use it for applications such as the one I've been working on. Simply it's not enough.
The application I'm talking about is an application for financial auditors. This is based on CPS
and make an heavy … Read more