[Zope] Z SQL Method problems (at least one confirmed bug)

Chris McDonough chrism@zope.com
Wed, 8 Aug 2001 00:10:04 -0400


Andy,

Thanks for the report!  I've put this in the Collector.  Hopefully we'll
confirm and fix it for 2.4.1.

Thanks again,

- C



----- Original Message -----
From: "Andy Dustman" <andy@dustman.net>
To: <zope@zope.org>
Sent: Tuesday, August 07, 2001 11:55 PM
Subject: [Zope] Z SQL Method problems (at least one confirmed bug)


> I *think* Z SQL Methods in Zope 2.4.0 are broken.
>
> I have a Z SQL Method (SELECT) with the following parameters:
>
> HostId DomainId Name IP
>
> and the following SQL:
>
> SELECT
> HostId, DomainId, RecordType, Name, IP, Distance, Target, TTL,
> StartEndTime, Location, Updated
> FROM Hosts
> <dtml-sqlgroup where>
> <dtml-sqltest HostId column="HostId" type=int optional>
> <dtml-and>
> <dtml-sqltest DomainId column="DomainId" type=int optional>
> <dtml-and>
> <dtml-sqltest Name column="Name" type=nb optional>
> <dtml-and>
> <dtml-sqltest IP column="IP" type=int optional>
> </dtml-sqlgroup>
>
> Note that all tested columns are optional. Using the Test tab, everything
> works correctly: If I leave off values, that portion isn't rendered.
>
> Now... I have a DTML Method which performs:
>
> <dtml-in SELECT mapping> ... </dtml-in>
>
> This bombs unless all the parameters are specified in form data. To
> diagnose this further, I hacked on Aqueduct.py a bit to return a bit more
> info on the error page:
>
>         if missing:
>             raise self.MissingArgumentError, (missing, args.items())
>
>  File /home/andy/Zope-2.4.0/lib/python/Shared/DC/ZRDB/Aqueduct.py, line
> 150, in _argdata
>     (Object: SELECT)
> Bad Request: (['DomainId', 'Name', 'IP'], [('HostId', {}), ('DomainId',
> {}), ('Name', {}), ('IP', {})])
>
> This shows that there is no 'optional' being set for these items. (Note in
> this particular case HostId was supplied, so it is not "missing".)
>
> If I have overlooked something blatently obvious, please let me know.
>
> But wait! There's more. Supposedly you are able to specify default values
> for parameters, i.e. spam="no" eggs="yes". DC.Shared.ZRDB.Aqueduct.parse()
> seems to be what is supposed to do this. However, it fails miserably.
>
> def parse(text,
>           result=None,
>           keys=None,
>           unparmre=re.compile(
>               r'([\000- ]*([^\000- ="]+))'),
>           parmre=re.compile(
>               r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'),
>           qparmre=re.compile(
>               r'([\000- ]*([^\000- ="]+)="([^"]*)")'),
>           ):
>
> Why the regexes are there as default parameters is beyond me. Nothing in
> ZRDB seems to make use of that "feature". Defining those regexes in the
> body of the function does seem to make it work again, so this is certainly
> a bug. Interestingly, it also changes the error slightly on the first
> problem:
>
> Bad Request: (['DomainId', 'Name', 'IP'], [('HostId', {'default': '1'}),
> ('DomainId', {}), ('Name', {}), ('IP', {})])
>
> Note that a default is now present (because I set one).
>
> For the record, I am using Python-2.1.1. However, I think I saw the second
> problem with Python-2.1.
>
> --
> Andy Dustman         PGP: 0xC72F3F1D
>     @       .net     http://dustman.net/andy
> I'll give spammers one bite of the apple, but they'll
> have to guess which bite has the razor blade in it.
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>