[orm-devel] Re: ORM mailing list inquiry...

Diedrich Vorberg diedrich at tux4web.de
Sun Mar 28 11:34:11 CEST 2004


Hi Charles!

>I tried to check out the latest cvs source, but got the following response:
>cvs -d :pserver:anonymous at cvs.tux4web.de:/var/data/public_cvs login
>Logging in to :pserver:anonymous at cvs.tux4web.de:2401/var/data/public_cvs
>CVS password:
>cvs [login aborted]: unrecognized auth response from cvs.tux4web.de: Unknown
>command: `pserve'
>
>maybe a typo in the /etc/xinetd.d/pserver conf file?
It seems my inetd.conf got truncated. Please try again.

>One feature that I'm thinking about adding is a count method to the
>datasource.select.  (inspired by SQLObject...)  This would wrap the SQL
>COUNT(*) statement and might be handy when doing selects in batches.  I was
>using this as a low cost test for the existence of a specific column value,
>but fetchall() should work fine in this case since there should only ever be
>zero or one value.
Hm.. I'll think about a count() function.
SelectResults do have a len(), see next question.

>When testing if a fetchone() returned a value as follows:
>item = conn.select(MapItems, dkey-"sam").fetchone()
>if item:
>
>I get:
>  File
>"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site
>-packages/orm/dbclass.py", line 299, in __getattr__
>    if name[0] == "_": return self.__dict__[name]

>KeyError: '__nonzero__'
I've added a dbclass.__nonzero__() function which is called by the
"if". You might want to check then len of the result:

   result = conn.select(MapItems, dkey-"sam").fetchone()
   if len(result) == 0:
      # no result
   else:
      # result

Also see the datasource.selectByPrimaryKey() function (which will
raise an exception if there is no such object).

>It looks like __getattr__ is assuming that a attribute/column name is going
>to be sent along.  Would it make sense to change name to a keyword argument
>with a default value set to return the dbclass (or a copy)?
That's not quite it: all method calles require attribute access to
aquire the function pointer. This attribute access is intercepted by
__getattr__() which is why the error occurs there.

>#######################################
>> Documentation is behind... I know...:-(
>I'll try to help out if I can... need to look into editing docbook formats.
I was going to switch to RestructuredText (see docutils.sf.net). If
you like you can get cvs write access...

>I better go ahead and send this before it gets any longer.  :)  Thanks for
>the help Diedrich.
No problem!

Best wishes
Diedrich

-- 
Diedrich Vorberg <diedrich at tux4web.de>      .---.   /             \
http://tux4web.de Tel: 02302 425269        /     \ ((__-^^-,-^^-__))
                                           \.O-O./  `-_---' `---_-'
"Unix is simple, but it takes a genius     /`\_/`\   `--|o` 'o|--'
to understand the simplicity."            //  _  \\     \  `  /
                      - Dennis Ritchie   | \     )|_     ): :(
                                        /`\_`>  <_/ \    :o_o:
     Associate Member of the FSF #1245  \__/'---'\__/     "-"



More information about the orm-devel mailing list