[Zope-DB] Return a Null string instead of a "None" string, DCOracle2

Remy Pinsonnault remy_pinsonnault at roche.ca
Mon May 3 10:32:38 EDT 2004


So if it's the DA do you know what piece of code to change?

Michael Mauws suggested me to to add null=" " to all my dtml-var or to
add a nvl function to all my returned values...

I can't find a better solution yet but it will be a huge amount of work...

Still searching

Thanks again

-----Original Message-----
From: Matthew T. Kromer [mailto:matt at bane.mi.org] 
Sent: April 30, 2004 12:11 PM
To: remy_pinsonnault at roche.ca
Cc: zope-db at zope.org
Subject: Re: [Zope-DB] Return a Null string instead of a "None" string,
DCOracle2


No, you don't want that.  I think its the DA that is converting a zero 
length string to None for you.


On Apr 30, 2004, at 10:58 AM, Remy Pinsonnault wrote:

> Now that I know that, how can I receive NULL or a zero-length string
> instead
> of the None singleton? This would fix my problem...
>
> I modified the following code but it does not help:
>
> #ifndef ZEROLENISNULL
> #define ZEROLENISNULL 1
> #endif
>
> Is it the right thing to do to receive a zero-length instead of None? 
> I don't think so beceause the only time this code is called is in the 
> ResultSetItem_value function and it returns again Py_None after having 
> checked if ZEROLENISNULL is true and len equals 0 :
>
> #if ZEROLENISNULL
>  if (len == 0)
>  {
>   Py_INCREF(Py_None);
>   TRACE(T_EXIT,("sAs", "ResultSetItem_value", Py_None,
>    "0 Len"));
>   return Py_None;
>  }
> #endif
>
> Thanks again
>
> Remy
>
> -----Original Message-----
> From: Matthew T. Kromer [mailto:matt at bane.mi.org]
> Sent: April 30, 2004 11:29 AM
> To: remy_pinsonnault at roche.ca
> Cc: zope-db at zope.org
> Subject: Re: [Zope-DB] Return a Null string instead of a "None" 
> string, DCOracle2
>
>
> Yes, if you're using Zope, it will likely convert the None singleton 
> to "None" for you because it ended up doing a string conversion at 
> some time with a <dtml-var> tag.
>
> Remy Pinsonnault wrote:
>
>> Thanks for your quick response Matt!
>>
>> I already have dco2.c version 1.137.
>>
>> What flag do I have to change to return a NULL instead of a None 
>> singleton? I changed ZEROLENISNULL to 1 as you suggested but it does 
>> not help... The more I think about this the more I think the problem 
>> is not in dco2 but in Zope?? When I do a <dtml-var> of the result, I 
>> get literally "None" in my application. Could it be that Zope 
>> interprets the None singleton as a "None"?? This only occurs for 
>> columns of type varchar2...
>>
>> One detail: there is a missing bracket ({) in source code:
>>
>> #if ZEROLENISNULL
>>  if (len == 0)
>>  {
>>   Py_INCREF(Py_None);
>>   TRACE(T_EXIT,("sAs", "ResultSetItem_value", Py_None,
>>    "0 Len"));
>>   return Py_None;
>>  }
>> #endif
>>
>> Thanks
>>
>> Remy
>>
>>     -----Original Message-----
>>     *From:* Matthew T. Kromer [mailto:matt at bane.mi.org]
>>     *Sent:* April 30, 2004 7:37 AM
>>     *To:* remy_pinsonnault at roche.ca
>>     *Cc:* zope-db at zope.org
>>     *Subject:* Re: [Zope-DB] Return a Null string instead of a "None"
>>     string, DCOracle2
>>
>>     DCOracle2 never returns "None" as a string -- it will return the
>>     None singleton. There's a compile time flag in the source that
>>     controls the behavior of if a zero-length result is returned as
>>     None or not. The default is for this to be OFF, but this is
>>     something that is only in the CVS source -- the 1.3 release
>>     doesn't have that change in it.
>>
>>
>>     On Apr 29, 2004, at 3:59 PM, Remy Pinsonnault wrote:
>>
>>         Hi,
>>
>>         I'm running the last DCOracle2 version under Windows XP,
>>         Oracle 9i and Python 2.3.
>>
>>         Right now the product returns a string containing "None" when
>>         the result is a zero-length varchar2 (NULL). How can I change
>>         this behaviour?
>>
>>         Can i change something in the source code to get a Null value?
>>         At least if I could modify the "None" string to something
>>         else it would be better because the application is in spanish
>>         and None doesn't look good...
>>
>>         Thanks in advance
>>
>>         Remy Pinsonnault
>>         Information Technology Specialist
>>         PERCAN PROJECT
>>         ROCHE LIMITED, CONSULTING GROUP
>>         _______________________________________________
>>         Zope-DB mailing list
>>         Zope-DB at zope.org
>>         http://mail.zope.org/mailman/listinfo/zope-db
>>
>
>





More information about the Zope-DB mailing list