← Back to team overview

configglue team mailing list archive

[Bug 849937] [NEW] Unable to specify raw strings for multi-level DictOption

 

Public bug reported:

I'm trying to get the following schema work well with configglue (needed
for proper Django LOGGING setting support in django-configglue):

# Schema definition

formatters = schema.DictOption(raw=True)

# JSON example

[logging]
formatters = {"sample": {"format": "%(name)s"}}

This fails because if raw=True, configglue won't return the embedded
dict, but the unicode representation of it. When I want to be more
specific, it fails in a more obscure way:

formatters = schema.DictOption(raw=True,
item=schema.DictOption(raw=True))

Traceback (most recent call last):
  File "moricka.py", line 24, in <module>
    op, opts, args = glue.schemaconfigglue(scp)
  File "/usr/lib/python2.7/site-packages/configglue/glue.py", line 70, in schemaconfigglue
    kwargs['default'] = parser.get(section.name, option.name)
  File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 497, in get
    value = self.parse(section, option, value)
  File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 344, in parse
    value = option_obj.parse(value, **kwargs)
  File "/usr/lib/python2.7/site-packages/configglue/schema.py", line 671, in parse
    value = option.parse(value, **kwargs)
  File "/usr/lib/python2.7/site-packages/configglue/schema.py", line 646, in parse
    sections = value.split()
AttributeError: 'dict' object has no attribute 'split'

# Section-based example

[logging]
formatters = formatters

[formatters]
sample = formatter_sample

[formatter_sample]
format = %(name)s

This one fails because it is trying to interpolate the value, even
though raw=True, so this seems totally wrong to me:

Traceback (most recent call last):
  File "moricka.py", line 24, in <module>
    op, opts, args = glue.schemaconfigglue(scp)
  File "/usr/lib/python2.7/site-packages/configglue/glue.py", line 70, in schemaconfigglue
    kwargs['default'] = parser.get(section.name, option.name)
  File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 497, in get
    value = self.parse(section, option, value)
  File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 344, in parse
    value = option_obj.parse(value, **kwargs)
  File "/usr/lib/python2.7/site-packages/configglue/schema.py", line 652, in parse
    parsed = dict(parser.items(value))
  File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 204, in items
    raise e
ConfigParser.InterpolationMissingOptionError: Bad value substitution:
	section: [bar_dict]
	option : blah
	key    : name
	rawval : 

I attach the few-line file I played around with while trying to
investigate why this wouldn't work with django-configglue.

** Affects: configglue
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of
Configglue developers, which is the registrant for configglue.
https://bugs.launchpad.net/bugs/849937

Title:
  Unable to specify raw strings for multi-level DictOption

Status in configglue:
  New

Bug description:
  I'm trying to get the following schema work well with configglue
  (needed for proper Django LOGGING setting support in django-
  configglue):

  # Schema definition

  formatters = schema.DictOption(raw=True)

  # JSON example

  [logging]
  formatters = {"sample": {"format": "%(name)s"}}

  This fails because if raw=True, configglue won't return the embedded
  dict, but the unicode representation of it. When I want to be more
  specific, it fails in a more obscure way:

  formatters = schema.DictOption(raw=True,
  item=schema.DictOption(raw=True))

  Traceback (most recent call last):
    File "moricka.py", line 24, in <module>
      op, opts, args = glue.schemaconfigglue(scp)
    File "/usr/lib/python2.7/site-packages/configglue/glue.py", line 70, in schemaconfigglue
      kwargs['default'] = parser.get(section.name, option.name)
    File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 497, in get
      value = self.parse(section, option, value)
    File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 344, in parse
      value = option_obj.parse(value, **kwargs)
    File "/usr/lib/python2.7/site-packages/configglue/schema.py", line 671, in parse
      value = option.parse(value, **kwargs)
    File "/usr/lib/python2.7/site-packages/configglue/schema.py", line 646, in parse
      sections = value.split()
  AttributeError: 'dict' object has no attribute 'split'

  # Section-based example

  [logging]
  formatters = formatters

  [formatters]
  sample = formatter_sample

  [formatter_sample]
  format = %(name)s

  This one fails because it is trying to interpolate the value, even
  though raw=True, so this seems totally wrong to me:

  Traceback (most recent call last):
    File "moricka.py", line 24, in <module>
      op, opts, args = glue.schemaconfigglue(scp)
    File "/usr/lib/python2.7/site-packages/configglue/glue.py", line 70, in schemaconfigglue
      kwargs['default'] = parser.get(section.name, option.name)
    File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 497, in get
      value = self.parse(section, option, value)
    File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 344, in parse
      value = option_obj.parse(value, **kwargs)
    File "/usr/lib/python2.7/site-packages/configglue/schema.py", line 652, in parse
      parsed = dict(parser.items(value))
    File "/usr/lib/python2.7/site-packages/configglue/parser.py", line 204, in items
      raise e
  ConfigParser.InterpolationMissingOptionError: Bad value substitution:
  	section: [bar_dict]
  	option : blah
  	key    : name
  	rawval : 

  I attach the few-line file I played around with while trying to
  investigate why this wouldn't work with django-configglue.

To manage notifications about this bug go to:
https://bugs.launchpad.net/configglue/+bug/849937/+subscriptions


Follow ups

References