Personal tools
You are here: Home Members chrism software buildit_issues resolution of globals based on other globals
Navigation
Log in


Forgot your password?
 
Views
Issue 3 of buildit_issues [BUILDIT]
Title: resolution of globals based on other globals
Status: Rejected Security related: No
Description: You cannot base one global variable off of another. Maybe it is by design, but it seems to behave badly: >>> from buildit import context >>> from St...
From: Jeff Hammel on: Apr 30, 07 13:39
Anonymous User Last update: Jul 27, 07 19:44
Topic/class: Zope/bug Importance: medium
Version info: 1.0
Issue 3 Transcript
2 entries
= Reject - Entry #2 by chrism on Jul 27, 2007 7:44 pm

 Status: Pending => Rejected

Hi Jeff,

The error you're seeing is due to the fact that even if you're populating a "globals" section, you have to reference the "current section" using "./" within bracketed names to refer to another variable in the same section, e.g.:

[globals]
foo=bar
baz=${./foo}

as opposed to
[globals]
foo=bar
baz=${foo}

Only "builtin" names (currently "cwd", "username", "buildoutdir" and "platform") can be referenced without a "./" anywhere.

Working example:

import context
f = open('jefftest.ini', 'w')
f.write("[globals]\nfoo=bar\nbaz=${./foo}\n")
f.close()
c = context.Context('jefftest.ini')
print c.globals

________________________________________
= Request - Entry #1 by Anonymous User on Apr 30, 2007 1:39 pm

You cannot base one global variable off of another. Maybe it is by design, but it seems to behave badly:

>>> from buildit import context
>>> from StringIO import StringIO
>>> c = context.Context(StringIO("[globals]\nfoo=bar\nbaz=${foo}\n"))
No [globals] section in inifile <StringIO.StringIO instance at 0x2b58671d4320>
No [namespaces] section in inifile <StringIO.StringIO instance at 0x2b58671d4320>
>>> c.globals
{'username': 'jhammel', 'platform': 'linux-x86_64', 'buildoutdir': '/home/jhammel', 'cwd': '/home/jhammel'}
>>> c.interpolate('${baz}', None)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib64/python2.4/site-packages/buildit/context.py", line 138, in interpolate
    task)
  File "/usr/lib64/python2.4/site-packages/buildit/resolver.py", line 211, in resolve_value
    name)
buildit.resolver.MissingDependencyError: <MissingDependencyError in section named None, option named None, value '${baz}', offender 'baz'>


FYI, I have tried to contact you via email, but it seems my mail gets rejected on the basis of being spam.

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: