Hi,

The reason I am doing this is because I have multiple tables in my database
that have all the same fields and I want to be able to add tables to my
script at anytime.  These tables hold information about new clients.  The DB
design was not mine and it's how it works for a syslog application we are
using.

I want to be able to run through all of these tables and query information
and send emails based on the data pulled.  Since each table is going to be
accessed the same way I just want to loop through each table/sqlobject
class, query data and send an email.

Is there an easier way to do this?

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Ian Wilson
Sent: Thursday, January 25, 2007 8:18 PM
To: [email protected]
Subject: [TurboGears] Re: help with sqlobject classes at runtime


I am confused on why or what you are doing but try this:

Set the default to empty for level 2 and you won't get that error:

level2 = StringCol(default='')



On 1/25/07, Lee Connell <[EMAIL PROTECTED]> wrote:
>
> /// ERROR (if I don't override __init__ in my sqlobject class)///
> /////////////////////////////////////////////////////////////////
>     c = help.classFromModule('__main__', 'SyslogPoll2')()
>   File
>
"C:\Python24\lib\site-packages\sqlobject-0.7.2-py2.4.egg\sqlobject\declarati
> ve.py", line 93, in _wrapper
>     return fn(self, *args, **kwargs)
>   File
>
"C:\Python24\lib\site-packages\sqlobject-0.7.2-py2.4.egg\sqlobject\main.py",
> line 1203, in __init__
>     self._create(id, **kw)
>   File
>
"C:\Python24\lib\site-packages\sqlobject-0.7.2-py2.4.egg\sqlobject\main.py",
> line 1222, in _create
>     raise TypeError, "%s() did not get expected keyword argument %s" %
> (self.__class__.__name__, column.name)
> TypeError: SyslogPoll2() did not get expected keyword argument level2
>
>
>
> /// Calling Code ///
> ////////////////////
> class SyslogPoll2(SQLObject):
>     class sqlmeta:
>         table = "SyslogPoll"
>
>     level2 = StringCol()
>
> help = DBHelper()
> c = help.classFromModule('__main__', 'SyslogPoll2')()
>
>
>
> /// Helper Code ///
> ///////////////////
> class DBHelper:
>     def classFromModule (self, module, className):
>         mod = __import__ (module)
>         return getattr (mod, className)
>
>
>
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Patrick Lewis
> Sent: Tuesday, January 23, 2007 12:58 AM
> To: TurboGears
> Subject: [TurboGears] Re: help with sqlobject classes at runtime
>
>
> Not quite sure what the real problem you are facing is, but if all you
> want to do is call the 'send' method without instantiating your class,
> can you use the @staticmethod (or perhaps @classmethod) decorator?
> e.g.
>
> class SyslogPoll2(SQLObject):
>
>     @staticmethod
>     def send(data):
>         print data
>
> I don't think you want to be overriding sqlobject's __init__
> (http://www.sqlobject.org/SQLObject.html#initializing-the-objects),
> apparently that is Very Bad.
>
> If you want to do some introspection of the class to know what the
> class needs to initialize, you should be able to get everything you
> need out of SyslogPoll2.sqlmeta.columns attribute.
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.17.8/648 - Release Date: 1/23/2007
> 11:04 AM
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007
> 3:32 PM
>
>
>
> >
>


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007
3:32 PM
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007
3:32 PM
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to