#579: ProductizedHref fails for dicts as first argument
---------------------------+-----------------------
Reporter: olemis | Owner: olemis
Type: defect | Status: accepted
Priority: major | Milestone: Release 7
Component: multiproduct | Version:
Resolution: | Keywords: web href
---------------------------+-----------------------
Changes (by olemis):
* status: new => accepted
* owner: nobody => olemis
Old description:
> Productized Href breaks Href contract when dict objects are passed as
> first argument. See sample code below
>
> {{{!#py
>
> >>> from trac.web.href import Href
> >>> h = Href('/x/y')
> >>> p = dict(a=1,b=2,c=3)
> >>> h(p)
> '/x/y?a=1&c=3&b=2'
> >>> from multiproduct.hooks import ProductizedHref
> >>> help(ProductizedHref)
>
> >>> help(ProductizedHref)
>
> >>> phref = ProductizedHref(h, 'z')
> >>> phref(p)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "multiproduct/hooks.py", line 106, in __call__
> filter(lambda x: args[0].startswith(x), self.STATIC_PREFIXES):
> File "multiproduct/hooks.py", line 106, in <lambda>
> filter(lambda x: args[0].startswith(x), self.STATIC_PREFIXES):
> AttributeError: 'dict' object has no attribute 'startswith'
> }}}
New description:
Productized Href breaks Href contract when dict objects are passed as
first argument. See sample code below
{{{#!py
>>> from trac.web.href import Href
>>> h = Href('/x/y')
>>> p = dict(a=1,b=2,c=3)
>>> h(p)
'/x/y?a=1&c=3&b=2'
>>> from multiproduct.hooks import ProductizedHref
>>> help(ProductizedHref)
>>> help(ProductizedHref)
>>> phref = ProductizedHref(h, 'z')
>>> phref(p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "multiproduct/hooks.py", line 106, in __call__
filter(lambda x: args[0].startswith(x), self.STATIC_PREFIXES):
File "multiproduct/hooks.py", line 106, in <lambda>
filter(lambda x: args[0].startswith(x), self.STATIC_PREFIXES):
AttributeError: 'dict' object has no attribute 'startswith'
}}}
--
--
Ticket URL: <https://issues.apache.org/bloodhound/ticket/579#comment:2>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound issue tracker