RE: [Zope] ZODBC and dictionaties
See: http://lists.zope.org/pipermail/zpt/2001-December/002553.html For example code on converting your zsql method results to a dictionary. Scott -----Original Message----- From: Jeff Sacksteder [mailto:jwsacksteder@ramprecision.com] Sent: Tuesday, September 24, 2002 5:31 AM To: 'Julián Muñoz' Cc: 'zope@zope.org' Subject: RE: [Zope] ZODBC and dictionaties If you want to access the results of ZSQL queries from an ODBC connection, you will have to access them positionally. if your results are in a variable called result_set you can do something like this to list the contents of the first three columns for each row. for row in result_set: print row[0],row[1],row[2] An ugly workaround, but it works. Additionally, the odbc module is single threaded, so if you have a large query that takes two minutes to run, everyone else is blocked until it completes. -----Original Message----- From: Julián Muñoz [mailto:jmunoz@telefonica.net] Sent: Tuesday, September 24, 2002 8:21 AM To: Oliver Marx Cc: zope@zope.org Subject: Re: [Zope] ZODBC and dictionaties Some people use FreeTDS to connecto to Microsoft SQL Server On Sun, 22 Sep 2002, Oliver Marx wrote:
Dear List
I need to use Zope with an SQL server, but but but ZODBC which seems to be the standard DA for SQL server doesn't support dictionaries. Is there a proven solution to this problem?
\Oliver
__o _ \<_ (_)/(_) Saludos de Julián -.- DVD-record Tools for linux http://www.freesoftware.fsf.org/dvdrtools/ _______________________________________________ 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 ) _______________________________________________ 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 ) The information contained in this email message may be privileged and is confidential information intended only for the use of the recipient or any employee or agent responsible for delivering it to the intended recipient. Any unauthorized use, distribution or copying of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately and destroy the original message and all attachments from your electronic files.
Meilicke, Scott wrote:
See:
http://lists.zope.org/pipermail/zpt/2001-December/002553.html
For example code on converting your zsql method results to a dictionary.
Urm, I prefer my implementation: def recs2lod(recset, names=None): return recset.dictionaries ;-) but then again, you don't even really need to do that, as an example: for rec in recset: print rec['myrecord'] print getattr(rec,'myrecord') cheers, Chris
Hi. I'm a newbie, I'm using zope 5.1 + cmf 1.3 plone 1.0 beta I saw that with "sendmail" I can send email by HostMail object... But, How can i access to all member's email? I'd like to sent by email all new events/news... (where I have to put the code?) Thanks, Cristian
varro@iol.it writes:
I'm using zope 5.1 + cmf 1.3 plone 1.0 beta
I saw that with "sendmail" I can send email by HostMail object... Please be more careful, when you describe problems. You mean "Mailhost" rather than "HostMail".
But, How can i access to all member's email? You pass the "To" information inside the message as a "To" header:
<dtml-sendmail mailhost=...> To: <dtml-var expr="'address1, address2, ...'"> From: ... Subject: ... .... </dtml-sendmail> Note, that the mail headers must start in column 1! Now to the second part of your problem: how to get the list of email addresses: I can give you only a partial answer (because I am too lazy to look up the required details). I expect, "portal_membership" has a method to return the list of members. Say, it would be "getMembers" (may have a different name, use e.g. "DocFinder" to find it out). Then you could use something like: <dtml-var expr="','.join([m.email for m in portal_membership.getMembers() if m.email])"> The "[...]" is a so called list generator. You find details in the Python documentation. Dieter
Chris Withers wrote:
Chris Withers wrote:
def recs2lod(recset, names=None): return recset.dictionaries
dammit.
return recset.dictionaries()
Well, the point is that ZODBCDA returns a ZSQL-resultset which doesn't have the dictionaries attribute ;) \Oliver
yep that sucks, i do something like this to get dicts (probably wildly inefficient): def dictionaries(rs): 'Return a list of result objects as a list of dictionaries' r=[] a=r.append names=rs.names() for row in rs: d={} for n in names: d[n]=row[n] a(d) return r Chris Withers wrote:
Oliver Marx wrote:
Well, the point is that ZODBCDA returns a ZSQL-resultset which doesn't have the dictionaries attribute ;)
Why doesn't it?
that sucks :-(
Sorry for the wild goose chase...
Chris
_______________________________________________ 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 )
yep that sucks, i do something like this to get dicts (probably wildly inefficient):
What happens if you just treat the result set as a list of dicts? I've just been blindly using them in this way and it seems to work (this is with ZODBCDA against MSSQL 7.0): results = container.some_sql_query() for row in results: print row['id'], row['some_field'] return printed Julian.
participants (7)
-
Chris Withers -
Dieter Maurer -
Julian Melville -
Meilicke, Scott -
Oliver Marx -
peter sabaini -
varro@iol.it