Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

zc.buildout, substitution and templating

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


encolpe.degoute at free

Aug 27, 2009, 6:14 AM

Post #1 of 6 (819 views)
Permalink
zc.buildout, substitution and templating

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 - Zope-Dev [at] zope
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 )


jim at zope

Aug 27, 2009, 6:40 AM

Post #2 of 6 (784 views)
Permalink
Re: zc.buildout, substitution and templating [In reply to]

On Thu, Aug 27, 2009 at 9:14 AM, Encolpe Degoute<encolpe.degoute [at] free> 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?

> 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.

Jim

--
Jim Fulton
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
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 )


gary.poster at gmail

Aug 27, 2009, 11:59 AM

Post #3 of 6 (773 views)
Permalink
Re: zc.buildout, substitution and templating [In reply to]

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 - Zope-Dev [at] zope
> 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 )

_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


thomas at thomas-lotze

Sep 3, 2009, 10:04 AM

Post #4 of 6 (704 views)
Permalink
Re: zc.buildout, substitution and templating [In reply to]

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


_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


encolpe.degoute at free

Sep 12, 2009, 6:03 AM

Post #5 of 6 (623 views)
Permalink
Re: zc.buildout, substitution and templating [In reply to]

Thomas Lotze a écrit :
> 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'm agree.

> 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.

No opposition on this ?
Can I add it in the trunk or does anybody want a branch ?

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

_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


thomas at thomas-lotze

Sep 12, 2009, 9:43 AM

Post #6 of 6 (618 views)
Permalink
Re: zc.buildout, substitution and templating [In reply to]

Encolpe Degoute wrote:

> Can I add it in the trunk or does anybody want a branch ?

Do it on a branch, even if it seems trivial. At least you'll want to run
the tests on different systems before modifying the trunk, which will be
easier when you can check the changes out from a branch.

--
Thomas



_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.