zc.buildout, substitution and templating

4 messages Options
Embed this post
Permalink
Encolpe DEGOUTE () zc.buildout, substitution and templating
Reply Threaded More More options
Print post
Permalink
Hello,

These last days I was using collective.recipe.template and
gocept.recipe.env.

The second one just update options with os.environ.
Unix shell having their own substitution methods then '${' appearing in
the .installed.cfg. It just blows if you try to rerun 'bin/buildout.

As zc.buildout is using something near string.template I patched
gocept.recipe.env to replace '$' by '$$' and collective.recipe.template
to replace '$$' by '$'.
As _sub method in builout just split text around '$$' and join it again
with '$$' we need to make the replacement with the result of this method.

Is it the good way to deal with escaping data ?
Or is this a bug of zc.buildout ?

Regards,
--
Encolpe DEGOUTE
http://encolpe.wordpress.com/
http://encolpe.degoute.free.fr/
Logiciels libres, hockey sur glace et autres activités cérébrales


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Encolpe DEGOUTE () Re: [Zope-dev] zc.buildout, substitution and templating
Reply Threaded More More options
Print post
Permalink
If I'm understanding well the april thread about templating we should
concentrate our effort around collective.recipe.template.

Gary Poster a écrit :

> Shameless plug: try z3c.recipe.filetemplate.
> http://pypi.python.org/pypi/z3c.recipe.filetemplate .  Sounds like it
> does what you want out of the box.
>
> Gary
>
> On Aug 27, 2009, at 9:14 AM, Encolpe Degoute wrote:
>
>> Hello,
>>
>> These last days I was using collective.recipe.template and
>> gocept.recipe.env.
>>
>> The second one just update options with os.environ.
>> Unix shell having their own substitution methods then '${' appearing in
>> the .installed.cfg. It just blows if you try to rerun 'bin/buildout.
>>
>> As zc.buildout is using something near string.template I patched
>> gocept.recipe.env to replace '$' by '$$' and collective.recipe.template
>> to replace '$$' by '$'.
>> As _sub method in builout just split text around '$$' and join it again
>> with '$$' we need to make the replacement with the result of this
>> method.
>>
>> Is it the good way to deal with escaping data ?
>> Or is this a bug of zc.buildout ?
>>
>> Regards,
>> --
>> Encolpe DEGOUTE
>> http://encolpe.wordpress.com/
>> http://encolpe.degoute.free.fr/
>> Logiciels libres, hockey sur glace et autres activités cérébrales
>>
>> _______________________________________________
>> Zope-Dev maillist  -  [hidden email]
>> http://mail.zope.org/mailman/listinfo/zope-dev
>> **  No cross posts or HTML encoding!  **
>> (Related lists -
>> http://mail.zope.org/mailman/listinfo/zope-announce
>> http://mail.zope.org/mailman/listinfo/zope )
>
>


--
Encolpe DEGOUTE
http://encolpe.degoute.free.fr/
Logiciels libres, hockey sur glace et autres activités cérébrales


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Encolpe DEGOUTE () Re: [Zope-dev] zc.buildout, substitution and templating
Reply Threaded More More options
Print post
Permalink
In reply to this post by Encolpe DEGOUTE
Jim Fulton a écrit :

> On Thu, Aug 27, 2009 at 9:14 AM, Encolpe Degoute<[hidden email]> wrote:
>  
>> Hello,
>>
>> These last days I was using collective.recipe.template and
>> gocept.recipe.env.
>>
>> The second one just update options with os.environ.
>> Unix shell having their own substitution methods then '${' appearing in
>> the .installed.cfg. It just blows if you try to rerun 'bin/buildout.
>>    
>
> What error did you get?
>  

$ bin/buildout

...

Uninstalling plonesite.

Uninstalling _mr.developer.

Installing _mr.developer.

Generated script '/opt/python-envs/generic2.4/bolt-dev_gd/bin/develop'.

While:

Installing _mr.developer.

Getting option env:PS1.

Error: The option name in substitution, ${debian_chroot:+($debian_chroot)},

has invalid characters.

$ cat .installed.cfg

[buildout]

installed_develop_eggs =
/opt/python-envs/generic2.4/bolt-dev_gd/develop-eggs/plone.recipe.apache.egg-link

parts = env lxml zope2 zeoserver instance supervisor apache initd zopepy
test omelette pydev _mr.developer

[env]

$ bin/buildout

...

While:

Installing.

An internal error occured due to a bug in either zc.buildout or in a

recipe being used:

Traceback (most recent call last):

File
"/opt/python-envs/generic2.4/flsh-dev_gd/eggs/zc.buildout-1.2.1-py2.4.egg/zc/buildout/buildout.py",
line 1509, in main

getattr(buildout, command)(args)

File
"/opt/python-envs/generic2.4/flsh-dev_gd/eggs/zc.buildout-1.2.1-py2.4.egg/zc/buildout/buildout.py",
line 378, in install

old_options = installed_part_options[part].copy()

KeyError: '_mr.developer'


At that point I can only remove the .installed.cfg file.

>  
>> As zc.buildout is using something near string.template I patched
>> gocept.recipe.env to replace '$' by '$$' and collective.recipe.template
>> to replace '$$' by '$'.
>> As _sub method in builout just split text around '$$' and join it again
>> with '$$' we need to make the replacement with the result of this method.
>>
>> Is it the good way to deal with escaping data ?
>> Or is this a bug of zc.buildout ?
>>    
>
> That's a good question.  Buildout substitutions are always of the form
> ${section:option}, so conceivably buildout could ignore substitutions
> without a colon.  I suspect it would be better to always require
> escaping and make sure buildout provides a documented way to do so.
> OTOH, I can see the convenience of not requiring escaping variable
> substitutions wo colons.
>  
I will push that in launchpad.

--
Encolpe DEGOUTE
http://encolpe.degoute.free.fr/
Logiciels libres, hockey sur glace et autres activités cérébrales


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Thomas Lotze-2 () Re: zc.buildout, substitution and templating
Reply Threaded More More options
Print post
Permalink
In reply to this post by Encolpe DEGOUTE
Encolpe Degoute wrote:

> As zc.buildout is using something near string.template I patched
> gocept.recipe.env to replace '$' by '$$' and collective.recipe.template to
> replace '$$' by '$'.

For the record: gocept.recipe.env hasn't yet been patched; I'd rather
discuss the issue first before applying your patch.

> As _sub method in builout just split text around '$$' and join it again
> with '$$' we need to make the replacement with the result of this
> method.
>
> Is it the good way to deal with escaping data ? Or is this a bug of
> zc.buildout ?

I think it's a bug in zc.buildout if it cannot read the configuration
storage it wrote earlier itself. A good API for dealing with configuration
options shouldn't require client code such as recipes to care about
encoding and decoding values in order to work around the details of
buildout's option representation. This would be awkward and, as we can see
with the issue at hand, would only work if all client code handled the
encoding consistently.

I therefore propose fixing buildout so that it encodes option values when
writing .installed.cfg just as it would decode them when reading the file.

--
Thomas



_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers