<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>coder . cl &#187; pyxser</title>
	<atom:link href="http://coder.cl/category/projects/pyxser/feed/" rel="self" type="application/rss+xml" />
	<link>http://coder.cl</link>
	<description>web developer &#38; system programmer</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:07:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>instant xml api using pyxser</title>
		<link>http://coder.cl/2011/11/instant-xml-api-using-pyxser/</link>
		<comments>http://coder.cl/2011/11/instant-xml-api-using-pyxser/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 13:42:24 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyxser]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=1915</guid>
		<description><![CDATA[Probably you do not understand pyxser at all. It is a serializer and deserializer which converts Python objects into XML as plain text. Among JSON and other formats, XML can help in some tasks like transmitting object through the network, for example building API calls using remote queries. Here I will guide you on how [...]]]></description>
			<content:encoded><![CDATA[<p>Probably you do not understand <a href='http://coder.cl/products/pyxser/' title='Python XML Serialization'>pyxser</a> at all. It is a serializer and deserializer which converts Python objects into XML as plain text. Among JSON and other formats, XML can help in some tasks like transmitting object through the network, for example building API calls using remote queries. Here I will guide you on how to build an XML query API for your Django driven application in few minutes. You just need to understand how <a href='http://coder.cl/products/pyxser/' title='Python XML Serialization'>pyxser</a> works and how to use the pyxser module. Remember that you can see the documentation once it is installed, even if you do not have Internet, just by running the pydoc daemon with <tt>pydoc -p 8080</tt> and connecting to the port <i>8080</i> in your machine &mdash; you can choose another port if it is not working.</p>
<p><span id="more-1915"></span></p>
<p><br/></p>
<h3>tl;dr</h3>
<p>You can setup a query API that throws XML through HTTP under Django using pyxser.</p>
<p><br/></p>
<h3>advice</h3>
<p>All examples here are working, you must be really careful with the authentication and object permissions before using the routines in this post. So, try to wrap those routines correctly using the Django authentication components to filter query requests. Probably OAuth related modules may help. Also the examples are not using the Python and Django best practices, so you need to adjust them to fit the best practices requirements. Finally, do not take all examples very literal, they are just examples and this is just a proof of concept article.</p>
<p><br/></p>
<h3>serializing model objects</h3>
<p>The <a href='http://coder.cl/products/pyxser/' title='Python XML Serialization'>pyxser</a> extension &mdash; which is written in C and uses libxml2 as its basis for XML processing &mdash; has two main arguments for the serialization routines: <tt>obj</tt> and <tt>enc</tt>, where <tt>obj</tt> is the object to be serialized and <tt>enc</tt> is the XML encoding to be used, so you can serialize a <i>valid</i> object using <tt>pyxser.serialize(obj = my_object, enc = 'utf-8')</tt>. You can see the full <a href='http://coder.cl/products/pyxser/' title='Python XML Serialization'>pyxser</a> documentation using the pydoc command and looking forward for the pyxser module.</p>
<p>To serialize Django models, you need to restrict some fields, so you need to filter them, you do not need to worry about processing each model field, you just need to worry to filter the model fields properly using the <tt>selector</tt> argument and the <tt>depth</tt> argument. Take a look on the following decorator.</p>
<pre class="brush: python;">

import pyxser as px

def render_to_xml(**pyxser_args):
    def outer(f):
        @wraps(f)
        def inner_xml(request, *args, **kwargs):

            result = f(request, *args, **kwargs)
            r = HttpResponse(mimetype='text/xml')
            try:
                render = px.serialize(obj=result,
                                      enc='utf-8',
                                      **pyxser_args)
            except Exception, exc:
                render = &quot;&lt;pyxs:obj/&gt;&quot;
            if result:
                r.write(render)
            else:
                r.write(&quot;&lt;pyxs:obj/&gt;&quot;)
            return r
        return inner_xml
    return outer
</pre>
<p>If you apply the decorator above in a Django view, it will return the serialized object as <tt>text/xml</tt> to the HTTP client. So, your view must return a valid object to be serialized by pyxser. It applies the <tt>pyxser.serialize</tt> function to the given output from your view. Now take a look to a view which uses this decorator to throw XML.</p>
<pre class="brush: python;">
def get_class(kls):
    try:
        parts = kls.split('.')
        module = ".".join(parts[:-1])
        m = __import__(module)
        for comp in parts[1:]:
            m = getattr(m, comp)
        return m
    except:
        return False

## use an URL as follows:
## (r'x/g/(?P&lt;model&gt;[\w\.]+)/(?P&lt;oid&gt;\d+)/',
##  u'views_xml.get_model_object'),
@require_http_methods(["GET", "OPTIONS", "HEAD"])
@render_to_xml(selector=do_value_attrs, depth=2)
def get_model_object(request, model=None, oid=None):
    obj = object()
    try:
        db_model = get_class(model)
        obj = db_model.objects.get(pk=oid)
        return obj
    except Exception, exc:
        log.error(exc)
    return obj
</pre>
<p>The view above returns an object from the given model name <tt>model</tt> and the given primary key <tt>oid</tt>, and passes the <tt>do_value_attrs</tt> selector function as attribute selector to pyxser, and restrict the serialization <tt>depth</tt> to two levels. Remember that pyxser allows to serialize circular references and cross references between objects, so we need to restrict the serialization depth, in case of Django models we can work with 2 levels in almost all models and the field selector <tt>do_value_attrs</tt> can be defined as follows.</p>
<pre class="brush: python;">

DENIED_FIELDS = ['user', 'customer', 'users', 'customers']
DENIED_CLASSES = ['Related', 'Foreign', 'Many']

def is_allowed_class(fld):
    for nm in DENIED_CLASSES:
        if nm in fld.__class__.__name__:
            return False
    for nm in DENIED_FIELDS:
        if nm in fld.name:
            return False
    return True

def do_value_attrs(o):
    values = dict()
    if hasattr(o, '_meta') and hasattr(o._meta, 'fields'):
        for fldn in o._meta.fields:
            if is_allowed_class(fldn):
                values[fldn.name] = getattr(o, fldn.name)
    else:
        for kw in o.__dict__:
            values[kw] = getattr(o, kw)
    return values
</pre>
<p>Where we are filtering all fields in model objects that we do not want to serialize and all field classes that pyxser should not serialize for plain object transmision. Other objects which are not model related objects are serialized as plain Python objects using their dictionaries to get the object attributes, and also <tt>DENIED_FIELDS</tt> are skipped and <tt>DENIED_CLASSES</tt> are skipped too. The resulting XML for URLs like <i>/p/x/g/offer.models.Marca/1/</i> is as follows.</p>
<pre class="brush: xml;">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/"
          version="1.0"
          type="Marca"
          module="prod.models"
          objid="id3128007116"&gt;
  &lt;pyxs:prop type="unicode" name="nombre" size="4"&gt;Sony&lt;/pyxs:prop&gt;
  &lt;pyxs:prop type="long" name="id"&gt;1&lt;/pyxs:prop&gt;
  &lt;pyxs:prop type="unicode" name="slug" size="4"&gt;sony&lt;/pyxs:prop&gt;
&lt;/pyxs:obj&gt;
</pre>
<p>The pyxser serialization model holds <i>type information</i>, so any serialized object carries <i>type information</i> to be user in deserialization tasks, then you can handle the object back in any machine supporting pyxser and get the object deserialized to its original class using the <tt>unserialize</tt> function.</p>
<p><br/></p>
<h3>defining object containers</h3>
<p>The pyxser extension cannot handle Django model containers directly, I mean those returned by the <tt>all</tt> method in query sets. So, you need to create a plain container to hold those objects that are retrieved from the database. Take a look on following view.</p>
<pre class="brush: python;">
class Container(object):
    count = 0
    items = []
    def __init__(self):
        pass

def collect_filters(qd):
    data = qd.copy()
    filters = dict()
    for kw in data:
        if kw.startswith('filter__'):
            name = kw.replace('filter__', '')
            filters[name] = data[kw]
    return filters

### use an URL as follows:
### (r'x/l/(?P&lt;model&gt;[\w\.]+)/(?P&lt;limit&gt;\d+)/',
###  u'views_xml.get_model_list'),
@require_http_methods(["GET", "OPTIONS", "HEAD"])
@render_to_xml(selector=select_value_attrs, depth=4)
def get_model_list(request, model=None, limit=1):
    container = Container()
    container.count = 0
    container.items = []
    try:
        db_model = get_class(model)
        filters = collect_filters(request.GET)
        objs = db_model.objects.filter(**filters).all()[0:limit]
        container.count = len(objs)
        container.items = map(lambda x: x, objs)
        return container
    except Exception, exc:
        log.error(exc)
    return container
</pre>
<p>If you take a look carefully to this example, you will notice that we are using a very simple <tt>Container</tt> class to hold your objects. The resulting XML for the URL <i>/p/x/l/prod.models.Marca/5/?filter__nombre__contains=son</i> is as follows.</p>
<pre class="brush: xml;">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/"
          version="1.0"
          type="Container"
          module="prod.views_xml"
          objid="id3107379372"&gt;
  &lt;pyxs:prop type="int" name="count"&gt;3&lt;/pyxs:prop&gt;
  &lt;pyxs:col type="list" name="items"&gt;
    &lt;pyxs:obj type="Marca" module="prod.models" objid="id3107380204"&gt;
      &lt;pyxs:prop type="unicode" name="nombre" size="5"&gt;Epson&lt;/pyxs:prop&gt;
      &lt;pyxs:prop type="long" name="id"&gt;10&lt;/pyxs:prop&gt;
      &lt;pyxs:prop type="unicode" name="slug" size="5"&gt;epson&lt;/pyxs:prop&gt;
    &lt;/pyxs:obj&gt;
    &lt;pyxs:obj type="Marca" module="prod.models" objid="id3107380300"&gt;
      &lt;pyxs:prop type="unicode" name="nombre" size="8"&gt;Ericsson&lt;/pyxs:prop&gt;
      &lt;pyxs:prop type="long" name="id"&gt;15&lt;/pyxs:prop&gt;
      &lt;pyxs:prop type="unicode" name="slug" size="8"&gt;ericsson&lt;/pyxs:prop&gt;
    &lt;/pyxs:obj&gt;
  &lt;/pyxs:col&gt;
&lt;/pyxs:obj&gt;
</pre>
<p>The resulting XML serialized object holds three Marca objects and all of them have their <tt>type</tt> to be deserialized once they are retrieved. If you want your objects to be deserialized back, you just need to use the <tt>pyxser.unserialize</tt> function properly, which is documented in the pyxser extension itself. I hope that you will like how pyxser works.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2011 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2011. | <a href="http://coder.cl/2011/11/instant-xml-api-using-pyxser/">Permalink</a> | <a href="http://coder.cl/2011/11/instant-xml-api-using-pyxser/#comments">One comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2011/11/instant-xml-api-using-pyxser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>pyxser stats</title>
		<link>http://coder.cl/2011/10/pyxser-stats/</link>
		<comments>http://coder.cl/2011/10/pyxser-stats/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 00:23:50 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[pyxser]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=1898</guid>
		<description><![CDATA[As you know I am the main developer &#8212; and unique developer, I hope more people will be interested in the future &#8212; of the pyxser project. It has a very specific purpose, but it is the only stand alone Python Object to XML serializer that exists. There is also the serialization routine built-in in [...]]]></description>
			<content:encoded><![CDATA[<p>As you know I am the main developer &mdash; and unique developer, I hope more people will be interested in the future &mdash; of the <i>pyxser</i> project. It has a very specific purpose, but it is the only stand alone Python Object to XML serializer that exists. There is also the serialization routine built-in in the <i>lxml</i> extension. The project is hosted on Source Forge, not popular as Git Hub does, but it is a well known project hosting site. The fact is that it is linked from sites and recommended along the Internet by some people. It provides a nice serialization model that allows you to standardise the XML serialization.</p>
<p><span id="more-1898"></span></p>
<p>It has been downloaded by many people from different sources where it is distributed, reaching about 8.000 downloads from different locations. That makes me very happy, because it is being tested and used widely in real world applications.</p>
<div class="figure">
<a href="http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/10/pyxser-stats.png" title="Pyxser Downloads Stats" target="_blank"><img src="http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/10/pyxser-stats.png" border="0" alt="Pyxser Downloads Stats"/></a></p>
<div>Pyxser Downloads Stats</div>
</div>
<p>Is a real pleasure to know that it is helping in the development of many applications. Also some other projects like <tt>jquery-validators</tt> it&#8217;s being downloaded over 3.000 times. I think that the best features of <i>pyxser</i>, is the fact it can do circular and cross referenced serialization without crashing. Remember that .NET and Java does not support circular and cross referenced XML serialization, so I have reached the right serialization model with <i>pyxser</i>. I have plans to migrate the serialization model and algorithm to other platform, like Java.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2011 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2011. | <a href="http://coder.cl/2011/10/pyxser-stats/">Permalink</a> | <a href="http://coder.cl/2011/10/pyxser-stats/#comments">One comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2011/10/pyxser-stats/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>comparing pyxser and jsonx</title>
		<link>http://coder.cl/2011/04/comparing-pyxser-and-jsonx/</link>
		<comments>http://coder.cl/2011/04/comparing-pyxser-and-jsonx/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 15:05:41 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[pyxser]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=1455</guid>
		<description><![CDATA[If you are a pyxser user, you may know that it uses a standard and structured serialization model. It was designed on January of 2009, and his target from that date until today is to generate a universal serialization model, so it can be ported to other languages easily, and maintain its more interesting features, [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a <a href='http://coder.cl/products/pyxser/' title='Python XML Serialization, pyxser'>pyxser</a> user, you may know that it uses a standard and structured serialization model. It was designed on <a href='http://coder.cl/2009/01/pyxser-serialization-redesign-and-becoming-strict/' title='Initial pyxser Serialization Model'>January of 2009</a>, and his target from that date until today is to generate a universal serialization model, so it can be ported to other languages easily, and maintain its more interesting features, like <i>cross reference</i> and <i>circular reference</i> serialization capability.</p>
<p><span id="more-1455"></span></p>
<p>At other side, JSONx is an IBM standard that has as main purpose to build XML representation of JSON objects. It is using a model very similar to the <strong>pyxser</strong> model, but restricted to JSON supported data types, so it is not extensible like pyxser. It only supports objects, arrays, booleans, strings, numbers, and nulls. The pyxser side is quite simple, it has objects, collections and plain properties. Objects can hold other objects, collections and properties; collections can hold other objects and properties and properties can hold <i>only</i> plain text data types, but flexible enough to create a custom serialization and hold a Base 64 encoded binary string and similar stuff.</p>
<div class="figure">
<a href='http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/04/JSONx.png' title='JSONx Structure' target='_blank'><img src='http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/04/JSONx.png' border='0' alt='JSONx Structure' /></a></p>
<div>JSONx Structure</div>
</div>
<p>JSONx is more complex than pyxser. It is doing the same <u>mistakes</u> than other serializers, since it holds the <i>data type</i> on the XML element itself. Instead, pyxser is doing the task of placing the data type and namespace on separate attributes. The data type is stored on the <tt>type</tt> attribute and the namespace is stored on the <tt>module</tt> attribute. We can talk about JSONx as <i>domain specific</i> XML serialization, at the pyxser side, we can talk as <i>domain abstraction</i> serialization model.</p>
<div class="figure">
<a href='http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/04/pyxser.png' title='PyXSer Structure' target='_blank'><img src='http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/04/pyxser.png' border='0' alt='PyXSer Structure' /></a></p>
<div>JSONx Structure</div>
</div>
<p>The JSONx model is not available through public XML Schema, its XML Schema is held inside IBM products. You can search for the pyxser XML Schema here, on its public URL: <a href='http://projects.coder.cl/pyxser/dtd/pyxser-1.0.xsd'>pyxser XML Schema</a>, and the serialization model implementation is available for the Python language as Python Extension (a module written in C) and you can find it here: <a href='http://coder.cl/products/pyxser/' title='pyxser'>pyxser</a>. The JSONx reference can be found here: <a href='http://publib.boulder.ibm.com/infocenter/wsdatap/v3r8m1/index.jsp?topic=/xs40/convertingbetweenjsonandjsonx05.htm' title='JSONx'>JSONx</a>. Also you can find pyxser XML document definitions in the form of XML schemas and DTD, and it is distributed with the pyxser Python extension:</p>
<ul>
<li><a href='http://projects.coder.cl/pyxser/dtd/pyxser-1.0.xsd'>pyxser XML Schema.</a></li>
<li><a href='http://projects.coder.cl/pyxser/dtd/pyxser-1.0-c14n.xsd'>pyxser XML Schema, C14N Compatible.</a></li>
<li><a href='http://projects.coder.cl/pyxser/dtd/pyxser-1.0.dtd'>pyxser XML DTD.</a></li>
<li><a href='http://projects.coder.cl/pyxser/dtd/pyxser-1.0-c14n.dtd'>pyxser XML DTD, C14N Compatible.</a></li>
</ul>
<p>Understanding the pyxser XML Schema will drive you to understand its abstraction model. So, have fun implementing domain abstraction, instead of doing domain specific XML serializations.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2011 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2011. | <a href="http://coder.cl/2011/04/comparing-pyxser-and-jsonx/">Permalink</a> | <a href="http://coder.cl/2011/04/comparing-pyxser-and-jsonx/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2011/04/comparing-pyxser-and-jsonx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[ann] pyxser-1.5.2-r2.win32 was released</title>
		<link>http://coder.cl/2011/03/ann-pyxser-1-5-2-r2-win32-was-released/</link>
		<comments>http://coder.cl/2011/03/ann-pyxser-1-5-2-r2-win32-was-released/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 17:55:47 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyxser]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=1397</guid>
		<description><![CDATA[Dear pyxser users, I&#8217;m pleased to announce that I have released pyxser-1.5.2r-r2.win32. This is the same release as 1.5.2-r2, but for Win32 platform. It does not add new features or similar stuff, it&#8217;s just a compiled binary distribution for Windows machines. You can download this release build for Python 2.7 and Win32 machines on SourceForge. [...]]]></description>
			<content:encoded><![CDATA[<p>Dear <a href="http://coder.cl/products/pyxser/">pyxser</a> users, I&#8217;m pleased to announce that I have released <b>pyxser-1.5.2r-r2.win32</b>. This is the same release as 1.5.2-r2, but for Win32 platform. It does not add new features or similar stuff, it&#8217;s just a compiled binary distribution for Windows machines. You can download this release build for Python 2.7 and Win32 machines on SourceForge. Please follow the following link to download the <a href='https://sourceforge.net/projects/pyxser/files/pyxser-1.5.2-r2/'>pyxser-1.5.2-r2.win32</a> package. It uses the Windows Installer and it&#8217;s an executable. You just need to download an official Python 2.7 distribution to use this release.</p>
<p><span id="more-1397"></span></p>
<p>Some notes on performance. Windows has a very poor performance compared to Linux and FreeBSD platforms. Please check the following plot that compares the performance on Windows, Linux and FreeBSD:</p>
<div class="figure">
<a href='http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/03/profile-1.5.2.png?v=4.0' title='Compare pyxser-1.5.2 on Windows, Linux and FreeBSD'><img src='http://coder.cl.qfl.wpcdn.arcostream.com/uploads/2011/03/profile-1.5.2.png?v=4.0' alt='Compare pyxser-1.5.2 on Windows, Linux and FreeBSD' border='0' /></a></p>
<div>Compare pyxser-1.5.2 on Windows, Linux and FreeBSD</div>
</div>
<p>The performance on Windows is very poor. The effort required to migrate the source from POSIX platforms to Windows platforms is minimum. The difference the major effort was made on porting the setup script. My code is almost standard and it requires a C99 compiler, and usually I use the flags <tt>-Wall -Wextra -Wshadow -pedantic -std=c99</tt> to compile my sources, so I&#8217;m using very strict dialect. Seems that the Windows C compiler is C90 by default. No way to deal with the Windows compiler for some C keywords. I&#8217;m expecting to bring constant support for Win32 platform on future releases. I will be waiting your feedback :)</p>
<p>Some notes on the FreeBSD install, is the fact that it is a standard distribution, without kernel optimization and it is using distribution binaries &mdash; that means that everything is made for 80&#215;386 machines &mdash; and also it does not have any compiler optimization. Also, is well known that FreeBSD default binaries are slow, mainly because it lacks kernel optimization and standard C library optimizations. The libxml2 port on FreeBSD seems to be the problem, since it is not using the jemalloc library, and it is using the internal libxml2 memory allocator.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2011 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2011. | <a href="http://coder.cl/2011/03/ann-pyxser-1-5-2-r2-win32-was-released/">Permalink</a> | <a href="http://coder.cl/2011/03/ann-pyxser-1-5-2-r2-win32-was-released/#comments">One comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2011/03/ann-pyxser-1-5-2-r2-win32-was-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[ann] pyxser-1.5.2r was released</title>
		<link>http://coder.cl/2011/01/ann-pyxser-1-5-2r-was-released/</link>
		<comments>http://coder.cl/2011/01/ann-pyxser-1-5-2r-was-released/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 15:14:41 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyxser]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=1203</guid>
		<description><![CDATA[Dear pyxser users, I&#8217;m pleased to announce that I&#8217;ve released pyxser-1.5.2r. This release adds backport support for Python 2.4 and few algorithm enhancements. As you know this serializer supports cross references and circular references, and have a wide variety of serialization options for your object trasmition and storage tasks. Please feel free to send me [...]]]></description>
			<content:encoded><![CDATA[<p>Dear <a href="http://coder.cl/products/pyxser/">pyxser</a> users, I&#8217;m pleased to announce that I&#8217;ve released <b>pyxser-1.5.2r</b>. This release adds backport support for Python 2.4 and few algorithm enhancements. As you know this serializer supports cross references and circular references, and have a wide variety of serialization options for your object trasmition and storage tasks. Please feel free to send me your feedback and participate on the pyxser development. You can participate through the SourceForge mailing lists and forums. Also you can report bugs and send me your feedback through the SourceForge web site.</p>
<p><span id="more-1203"></span></p>
<p>The <i>ChangeLog</i> for this release is as follows:</p>
<pre>
1.5.2r (2011.01.08):

        Daniel Molina Wegener <dmw@coder.cl>

        * Added support for Python 2.4
        * Replaced the use of the commands package by the
        subprocess package on the setup script.
        * On the next release will be added support
        for Python 3.X ;)

        Thanks to pyxser users for their feedback.</pre>
<p><br/></p>
<h3>type backporting</h3>
<p>I&#8217;ve received an email from Juha Tuomala reporting incomapibility on pyxser to install it under Python 2.4. Also he has sent me a patch to make it work with Python 2.4. I&#8217;ve reviewed the patch and it was including some system macros, so it would be a little bit hard to include in the pyxser distribution. I&#8217;ve decided to study the problem about type backporting to make pyxser compatible with Python 2.4. The main problem was the <tt>Py_ssize_t</tt>, that is not available on Python 2.4, and used from Python 2.5 on the <tt>_PyTuple_Resize</tt> Python internal. The patch that Juha tried to send me was creating some macros to replace that type definition. But researching a little a about the <tt>Py_ssize_t</tt> type, I&#8217;ve found the <a href="http://www.python.org/dev/peps/pep-0353/">PEP353</a> that guides on how to backport the usage of the <tt>Py_ssize_t</tt> type.</p>
<pre name="code" class="c">
#if PY_VERSION_HEX &lt; 0x02050000 &amp;&amp; !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#endif
</pre>
<p>The preprocessor conditional block above can be used to backport the <tt>Py_ssize_t</tt> type without overwriting system types, and since it is a PEP, it should be the official way to backport that specific type. The other problem was about the <tt>PyAnySet_CheckExact</tt> macro. In this case, I&#8217;ve used the that portion of the patch directly, allowing me to backport some pyxser internal functions to Python 2.4</p>
<pre name="code" class="c">
#if PY_VERSION_HEX &lt; 0x02050000 &amp;&amp; !defined(PY_SSIZE_T_MIN)
#define Py_TYPE(ob)             (((PyObject*)(ob))->ob_type)
#define PyAnySet_CheckExact(ob) \
        (Py_TYPE(ob) == &amp;PySet_Type || Py_TYPE(ob) == &amp;PyFrozenSet_Type)
#endif
</pre>
<p>I&#8217;ve used the same technique to detect the Python version and use that specific macro just for the required Python version. This is not affecting the future versions of Pyxser. For the next pyxser release, I&#8217;m planning to port it to Python 3.X. I hope that you will enjoy trasmitting and sending Python objects in XML format using the pyxser serializer ;)</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2011 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2011. | <a href="http://coder.cl/2011/01/ann-pyxser-1-5-2r-was-released/">Permalink</a> | <a href="http://coder.cl/2011/01/ann-pyxser-1-5-2r-was-released/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2011/01/ann-pyxser-1-5-2r-was-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  coder.cl/category/projects/pyxser/feed/ ) in 0.37425 seconds, on Feb 7th, 2012 at 2:51 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 7th, 2012 at 3:51 am UTC -->
