Mailing List Archive

Patches to SybaseDA v2.0b2
Hi,

In migrating from Sybase 11.0.3 (old, free version for Linux) to Sybase 15
(free Linux Express version), I've had quite a number of troubles getting
SybaseDAv2b2 to work (under Zope 2.5.1). That said, the problems probably
had more to do with changing from Python 2.1.3 (Redhat 7.2) to Python 2.3.4
(RHEL 4.3).

In particular, the newer Python more stringently checks the parameters
passed to the PyArg_ParseTupleAndKeywords() function. sys_occ.c in
SybaseDAv2b2 has a very minor (but fatal) error in this regard that, because
of the new checks, cause the somewhat esoteric error message:

RuntimeError: more keyword list entries than argument specifiers

I've included below patches to two files, db.py and src/sys_occ.c, that fix
this error.

The patches also provide a workaround for the first error I encountered that
stumped me for a bit:

ct_command(): user api layer: external error: This routine cannot be
called while results are pending for a command that has been sent to the
server

This error occurred anytime I tried to access the database (i.e., I could
connect just fine, but could not run any queries). The solution simply adds
a call to "cm.ct_cancel(sy_occ.CS_CANCEL_ALL)" early on in the "query"
method to clear the pending results and hence stop this error from
occurring.

IMPORTANT CAVEAT: This call to cm.ct_cancel() may not be appropriate as a
general solution, as it's possible that the workaround will mess up a
multistep query, such as an INSERT, UPDATE, or DELETE transaction. The
proper fix would require finding out why SybaseDAv2b2 has some sort of
results pending even at the first call of the "query" method and then fixing
this by either retrieving the remaining results or cancelling the offending
query.

I presently only require read-only access for rather simply queries
from Zope to Sybase 15, so this workaround is fine for me for now. If
anyone investigates this further and has a better solution, I'd appreciate
knowing.

I hope this is helpful to some soul or souls out there. :) Sybase ASE 15 is
a great product, free for Linux for up to 5gb DBs and 2gb RAM, and worthy of
partnering with Zope for the presentation side of things.

Doug

P.S. the patch also corrects the erroneous duplication of the
CS_SUCCEED command entry (noted long ago on this list) and puts a try/catch
block around a call to "apply(converters[t], v)", also suggested by some
poster either on this or another list.


PATCH #1: db.py

*** db.py 2000-02-02 14:01:34.000000000 -0600
--- /opt/zope/lib/python/Products/SybaseDAv2/db.py 2006-04-19 19:00:13.000000000 -0500
***************
*** 178,184 ****
CS_IMAGE_TYPE=sy_occ.CS_IMAGE_TYPE,
CS_ROW_FAIL=sy_occ.CS_ROW_FAIL,
CS_END_DATA=sy_occ.CS_END_DATA,
- CS_SUCCEED=sy_occ.CS_SUCCEED,
CS_FMT_UNUSED=sy_occ.CS_FMT_UNUSED,
string_type=_string_types.has_key,
type_map=_type_map,
--- 178,183 ----
***************
*** 196,201 ****
--- 195,201 ----
for query in queries:

failed=0
+ cm.ct_cancel(sy_occ.CS_CANCEL_ALL)
if cm.ct_command(CS_LANG_CMD, query) != CS_SUCCEED: self._error()
if cm.ct_send() != CS_SUCCEED: self._error()

***************
*** 280,287 ****
v=x
else:
v=buf[0]
! if type(v) is TupleType:
! v=apply(converters[t], v)

row[i]=v
result.append(tuple(row))
--- 280,295 ----
v=x
else:
v=buf[0]
! # if type(v) is TupleType:
! # v=apply(converters[t], v)
! try:
! if type(v) is TupleType:
! v=apply(converters[t], v)
! except:
! cm.ct_cancel(sy_occ.CS_CANCEL_ALL)
! raise Error("Results field conversion error: converter=%s, v=%s" % \
! (str(converters[t]), str(v)))
!

row[i]=v
result.append(tuple(row))

PATCH #2: src/sy_occ.c

*** src/sy_occ.c 2000-02-02 14:01:34.000000000 -0600
--- /opt/zope/lib/python/Products/SybaseDAv2/src/sy_occ.c 2006-04-20 00:17:23.000000000 -0500
***************
*** 382,388 ****

static char *kwargs[] = {"name", "datatype", "format", "maxlength",
"scale", "precision", "status", "count",
! "usertype", "locale"};

if (!PyArg_ParseTupleAndKeywords(
args, kw, "|s#iiiiiiiiO!", kwargs,
--- 382,388 ----

static char *kwargs[] = {"name", "datatype", "format", "maxlength",
"scale", "precision", "status", "count",
! "usertype", "loc", NULL};

if (!PyArg_ParseTupleAndKeywords(
args, kw, "|s#iiiiiiiiO!", kwargs,
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: Patches to SybaseDA v2.0b2 [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 20 Apr 2006, at 23:40, Doug Morse wrote:
> I hope this is helpful to some soul or souls out there. :) Sybase
> ASE 15 is
> a great product, free for Linux for up to 5gb DBs and 2gb RAM, and
> worthy of
> partnering with Zope for the presentation side of things.

I honestly doubt that posting patches to a mailing list is all that
helpful. I suggest you contact the database adapter author(s)
instead. Postings to a mailing list are bound to get lost and forgotten.

jens

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFESBvURAx5nvEhZLIRAkpZAJ0Yx74gjACaOIGJgnVF0enZjZMzkQCdH/EN
v/hcMeBqR4/1s0pEcXBYGgc=
=W/XX
-----END PGP SIGNATURE-----
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: Patches to SybaseDA v2.0b2 [ In reply to ]
Hi Jens!

I very much agree, but unfortunately (a) I can find no authorship
information for this Zope product other than Digital Creations, with this
list (zope-db@zope.org) listed as the only contact information and (b) the
product hasn't been updated since early 2000. So, posting to this list was
the best I could come up with. If you happen to know who authored SybaseDA,
I'd be most happy to contact them. Indeed, I'd consider becoming the new
maintainer for this product so it can stay current, but would not want to do
so without first having a somewhat in-depth conversation with the author re:
the product's present strengths/weaknesses/limitations.

Regards,
Doug


On Fri, Apr 21, 2006 at 12:40:04AM +0100, Jens Vagelpohl wrote:
>
> I honestly doubt that posting patches to a mailing list is all that
> helpful. I suggest you contact the database adapter author(s)
> instead. Postings to a mailing list are bound to get lost and forgotten.
>
> jens
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: Patches to SybaseDA v2.0b2 [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Looking at cvs.zope.org the committers were "brian" (Brian Lloyd) and
"michel" (Mike Pelletier) and some work from "jeffrey" (Jeffrey
Shell). None of them are with ZC, and I doubt they are interested in
supporting the software.

You might be on your own with a package as outdated as this. I would
look for alternative solutions.

jens


On 21 Apr 2006, at 16:40, Doug Morse wrote:

> Hi Jens!
>
> I very much agree, but unfortunately (a) I can find no authorship
> information for this Zope product other than Digital Creations,
> with this
> list (zope-db@zope.org) listed as the only contact information and
> (b) the
> product hasn't been updated since early 2000. So, posting to this
> list was
> the best I could come up with. If you happen to know who authored
> SybaseDA,
> I'd be most happy to contact them. Indeed, I'd consider becoming
> the new
> maintainer for this product so it can stay current, but would not
> want to do
> so without first having a somewhat in-depth conversation with the
> author re:
> the product's present strengths/weaknesses/limitations.
>
> Regards,
> Doug
>
>
> On Fri, Apr 21, 2006 at 12:40:04AM +0100, Jens Vagelpohl wrote:
>>
>> I honestly doubt that posting patches to a mailing list is all that
>> helpful. I suggest you contact the database adapter author(s)
>> instead. Postings to a mailing list are bound to get lost and
>> forgotten.
>>
>> jens

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFESQTwRAx5nvEhZLIRAjyTAJ9UdY2a57IE+KJLwF56LVjfJejLAQCfeBrs
Nu41R3DU+q18IOWW4g7DMDU=
=3cvQ
-----END PGP SIGNATURE-----
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db