[Zope-Checkins] SVN: Zope/trunk/utilities/tracelog.py Added url summary statistics.
Log message for revision 41497: Added url summary statistics. Added HTML output that makes it easy to jump from a URL shown in a minute detail to the statistics for that URL. Changed: U Zope/trunk/utilities/tracelog.py -=- Modified: Zope/trunk/utilities/tracelog.py === --- Zope/trunk/utilities/tracelog.py2006-01-30 16:18:33 UTC (rev 41496) +++ Zope/trunk/utilities/tracelog.py2006-01-30 16:31:04 UTC (rev 41497) @@ -11,15 +11,15 @@ # FOR A PARTICULAR PURPOSE. # ## -Yet another trace log analysis tool +Yet another lag analysis tool + + $Id$ import datetime, optparse, sys - - class Request: output_bytes = '-' @@ -52,6 +52,60 @@ def total_seconds(self): return (self.end - self.start).seconds +class Times: + +tid = 1l + +def __init__(self): +self.times = [] +self.hangs = 0 +Times.tid += 1 +self.tid = Times.tid # generate a unique id + +def finished(self, request): +self.times.append(request.app_seconds) + +def hung(self): +self.hangs += 1 + +def impact(self): +times = self.times +if not times: +self.median = self.mean = self.impact = 0 +return 0 +self.times.sort() +n = len(times) +if n % 2: +m = times[(n+1)/2-1] +else: +m = .5 * (times[n/2]+times[n/2-1]) +self.median = m +self.mean = sum(times)/n +self.impact = self.mean * (n+self.hangs) +return self.impact + +def __str__(self): +times = self.times +if not times: +return 0 %5d % ( +self.hangs) + +n = len(times) +m = self.median +return %9.1f %5d %6.0f %6.2f %6.2f %6.0f %5d % ( +self.impact, n, times[0], m, self.mean, times[-1], self.hangs) + +def html(self): +times = self.times +if not times: +print td('', 0, '', '', '', '', self.hangs) +else: +n = len(times) +m = self.median +impact = 'a name=u%s%s' % (self.tid, self.impact) +print td(impact, n, times[0], m, self.mean, times[-1], + self.hangs) + def parsedt(s): date, time = s.split('T') return datetime.datetime(*( @@ -69,15 +123,33 @@ restarts = find_restarts(options.event_log) else: restarts = [] - + restarts.append(datetime.datetime.utcnow()+datetime.timedelta(1000)) +if options.html: +print_app_requests = print_app_requests_html +output_minute = output_minute_html +output_stats = output_stats_html +minutes_header = minutes_header_html +minutes_footer = minutes_footer_html +print 'html title=trace log statisticsbody' +else: +print_app_requests = print_app_requests_text +output_minute = output_minute_text +output_stats = output_stats_text +minutes_header = minutes_header_text +minutes_footer = minutes_footer_text + + +urls = {} [file] = args lmin = ldt = None requests = {} input = apps = output = n = 0 spr = spa = 0.0 restart = restarts.pop(0) +minutes_header() +remove_prefix = options.remove_prefix for record in open(file): record = record.split() typ, rid, dt = record[:3] @@ -89,7 +161,9 @@ print_app_requests(requests, ldt, options.old_requests, options.app_requests, + urls, \nLeft over:) +record_hung(urls, requests) requests = {} input = apps = output = n = 0 spr = spa = 0.0 @@ -98,18 +172,12 @@ if min != lmin: if lmin is not None: - -print lmin.replace('T', ' '), %4d I=%3d A=%3d O=%3d % ( -len(requests), input, apps, output), -if n: -print N=%4d %10.2f %10.2f % (n, spr/n, spa/n) -else: -print - +output_minute(lmin, requests, input, apps, output, n, spr, spa) if apps options.apps: print_app_requests(requests, dt, options.old_requests, options.app_requests, + urls, ) lmin = min spr = 0.0 @@ -117,8 +185,23 @@ n = 0 if typ == 'B': +if rid in requests: +request = requests[rid] +if request.state ==
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py * returning the correct old value for LOG
Log message for revision 69089: * returning the correct old value for LOG Changed: U Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py -=- Modified: Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py === --- Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py 2006-07-11 01:27:44 UTC (rev 69088) +++ Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py 2006-07-11 05:05:27 UTC (rev 69089) @@ -49,7 +49,7 @@ logger = logging.getLogger('Zope.ZCatalog') # BBB: some products apparently import 'LOG' from here! Gone in 2.10. -from zLOG import LOG +LOG = logger manage_addZCatalogForm=DTMLFile('dtml/addZCatalog',globals()) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
Re: [Zope] ZSQL Method Question
This is how it works for MySQL: insert into org (org_name, org_phone) values ('x', 'y') dtml-var sql_delimiter select LAST_INSERT_ID() as org_id You have to have the select LAST_INSERT_ID call in the same query as the insert, and you have to have the sql_delimiter. I assume you know that the x and y values should be sql-var ... types. Cliff Benjamin Menking wrote: New to python/Zope, old-timer on PHP I'm using MySQL and a ZSQL method to insert data into the database. ex: insert into org (org_name, org_phone) values ('x', 'y') What I'm trying to figure out is that org_id (also part of the org table, but not specified in the sql statement) is an auto_increment primary key field and in PHP I can use mysql_insert_id() to find out what org_id was set to after the mysql_query() call. Is there a way to retrieve that value with ZSQL method, or must I use some other mechanism? Thanks! ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZSQL Method Question
What if you have 1,000,000 requests/sec? What if between the INSERT and the LAST_INSERT_ID() another INSERT is made? I use PostgreSQL and with postgres you can always ask the sequence what the next id is going to be. It goes something like this:: next_id = context.GetNextId()[0].next_id context.SQLInsertUser(uid=next_id, name='Peter') where 'GetNextId' is a ZSQL method that looks like this:: params/params SELECT NEXTVAL('users_uid_seq') AS next_id Cliff Ford wrote: This is how it works for MySQL: insert into org (org_name, org_phone) values ('x', 'y') dtml-var sql_delimiter select LAST_INSERT_ID() as org_id You have to have the select LAST_INSERT_ID call in the same query as the insert, and you have to have the sql_delimiter. I assume you know that the x and y values should be sql-var ... types. Cliff Benjamin Menking wrote: New to python/Zope, old-timer on PHP I'm using MySQL and a ZSQL method to insert data into the database. ex: insert into org (org_name, org_phone) values ('x', 'y') What I'm trying to figure out is that org_id (also part of the org table, but not specified in the sql statement) is an auto_increment primary key field and in PHP I can use mysql_insert_id() to find out what org_id was set to after the mysql_query() call. Is there a way to retrieve that value with ZSQL method, or must I use some other mechanism? Thanks! ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZSQL Method Question
Peter Bengtsson wrote: What if you have 1,000,000 requests/sec? What if between the INSERT and the LAST_INSERT_ID() another INSERT is made? I use PostgreSQL and with postgres you can always ask the sequence what the next id is going to be. It goes something like this:: next_id = context.GetNextId()[0].next_id context.SQLInsertUser(uid=next_id, name='Peter') where 'GetNextId' is a ZSQL method that looks like this:: params/params SELECT NEXTVAL('users_uid_seq') AS next_id Its even easier: one ZSQL Method: INSERT INTO foo (foo_id,blah,bar) VALUES (nextval('foo_foo_id_seq'),dtml-sqlvar blah ... ); SELECT CURRVAL('foo_foo_id_seq') as foo_id; But your above solution is valid too. Regards Tino ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZSQL Method Question
Aloha, Is this even easier solution only for postgreSQL, or is it for MySQL? I am going to have to start working with integrating MySQL into zope-based stuff soon so I'm trying to get a head start... :-) thanks, John S. Tino Wildenhain wrote: Peter Bengtsson wrote: What if you have 1,000,000 requests/sec? What if between the INSERT and the LAST_INSERT_ID() another INSERT is made? I use PostgreSQL and with postgres you can always ask the sequence what the next id is going to be. It goes something like this:: next_id = context.GetNextId()[0].next_id context.SQLInsertUser(uid=next_id, name='Peter') where 'GetNextId' is a ZSQL method that looks like this:: params/params SELECT NEXTVAL('users_uid_seq') AS next_id Its even easier: one ZSQL Method: INSERT INTO foo (foo_id,blah,bar) VALUES (nextval('foo_foo_id_seq'),dtml-sqlvar blah ... ); SELECT CURRVAL('foo_foo_id_seq') as foo_id; But your above solution is valid too. Regards Tino ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) -- John Schinnerer - MA, Whole Systems Design -- - Eco-Living - Whole Systems Design Services People - Place - Learning - Integration [EMAIL PROTECTED] http://eco-living.net ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZSQL Method Question
Comment on Peter's suggestion: I am no expert on these things, but it is my understanding that for MySQL LAST_INSERT_ID() fetches the last autoincrement value made by the current insert, so the outcome is not affected by virtually simultaneous requests. And I don't think MySQL accepts a value for the autoincrement key. I am a bit surprised that the code you quote is reliable - surely there is a possibility of an insert after calling GetNextID and before calling SQLInsert in the python code? Comment on Tino's suggestion: I think that LAST_INSERT_ID() is MySQL specific and I guess CURRVAL() is Postgres specific. But the principle is the same: calling within the same Z SQL Method ought to be safe. Anyway, I hope John has had is question answered. Cliff Tino Wildenhain wrote: Peter Bengtsson wrote: What if you have 1,000,000 requests/sec? What if between the INSERT and the LAST_INSERT_ID() another INSERT is made? I use PostgreSQL and with postgres you can always ask the sequence what the next id is going to be. It goes something like this:: next_id = context.GetNextId()[0].next_id context.SQLInsertUser(uid=next_id, name='Peter') where 'GetNextId' is a ZSQL method that looks like this:: params/params SELECT NEXTVAL('users_uid_seq') AS next_id Its even easier: one ZSQL Method: INSERT INTO foo (foo_id,blah,bar) VALUES (nextval('foo_foo_id_seq'),dtml-sqlvar blah ... ); SELECT CURRVAL('foo_foo_id_seq') as foo_id; But your above solution is valid too. Regards Tino ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Catalog aware
Hi all! Is possible to create an object (for example a Page Template) and make it catalog aware? I wonder why the objects aren't catalogable by default (I need all my object catalogables) Any Idea? -- Mis Cosas http://blogs.sistes.net/Garito ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Catalog aware
--On 18. Juli 2006 15:14:54 +0200 Garito [EMAIL PROTECTED] wrote: Hi all! Is possible to create an object (for example a Page Template) and make it catalog aware? Look at the CatalogAware mixin class. I wonder why the objects aren't catalogable by default (I need all my object catalogables) Because Zope is not CMF and Zope is not Plone. Because you need this feature it does not mean that everyone needs this feature by default. -aj pgpdrZD8DeHle.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] external method with import tarfile
Hi! I am trying to run a external python script. Now I am facing a problem that occurs only when I run the script via Zope. ... import os,tarfile ... tar = tarfile.open(oname,r:gz) for itar in tar: tar.extract(itar.name,jobdir) gives me: Site Error An error was encountered while publishing this resource. Error Type: IOError Error Value: CRC check failed If I comment the for loop my scripts finish well, but then it does not uncompress the file. Please, any help would very appreciated. Many thanks in advance, Cheers, Alan -- Alan Wilter S. da Silva, D.Sc. - Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. http://www.bio.cam.ac.uk/~awd28 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] external method with import tarfile
--On 18. Juli 2006 16:12:18 +0100 Alan [EMAIL PROTECTED] wrote: Error Type: IOError Error Value: CRC check failed This is unlikely a Zope issue. Either your tar file is broken or the tarfile module is broken. Check if your code runs without Zope as a simple PythonScript..there is nothing about Zope involved in your issue. -aj pgp0ncqn4RhT4.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Using the DTML REQUEST Object
Dear Exalted Sirs and Madams, I'm a Zope newbie, so be gentle. I'm using DTML on Zope (yes I know Plone and Tal is now the norm) and I was wondering if regularly using the REQUEST(set and get) object is bad practice. I'm mostly a C++ programmer and I know of the horrors of global variables, but I was wondering if there was any way to pass information from DTML Documents to DTML Methods and vice versa (and maybe from DTML Methods to DTML Methods) without using the REQUEST object. Thanks and take care, Muk Yan ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Using the DTML REQUEST Object
--On 18. Juli 2006 13:33:59 -0400 Muk Yan [EMAIL PROTECTED] wrote: Dear Exalted Sirs and Madams, I'm a Zope newbie, so be gentle. I'm using DTML on Zope (yes I know Plone and Tal is now the norm) and I was wondering if regularly using the REQUEST(set and get) object is bad practice. It's *bad practice* I'm mostly a C++ programmer and I know of the horrors of global variables, but I was wondering if there was any way to pass information from DTML Documents to DTML Methods and vice versa (and maybe from DTML Methods to DTML Methods) without using the REQUEST object. If you need to pass parameters to other objects, pass them. -aj pgp0D1FbFchl8.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] ERROR ExtendedPathIndex attempt to unindex...
Getting this error when trying to install any Products in Plone site.Doesn't happen on newly created Plone site in same Zope Instance.Zope 2.8.5 Python 2.4.2 Plone 2.1.2Any help would be great. Thanks ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Using the DTML REQUEST Object
Muk Yan wrote: Dear Exalted Sirs and Madams, I'm a Zope newbie, so be gentle. I'm using DTML on Zope (yes I know Plone and Tal is now the norm) and No, Plone has nothing to do with TAL (although it uses it too) But nobody forces you to DTML either. You can use python scripts and ZPT (TAL) is just easy - much lesser to type. I was wondering if regularly using the REQUEST(set and get) object is bad practice. You should avoid that if possible. I'm mostly a C++ programmer and I know of the horrors of global variables, but I was wondering if there was any way to pass DTML is pure horror in this regard. You see every little object/variable everywhere. All namespaces are a big pile in DTML. You will have a hard time finding out if a value comes from REQUEST, REQUEST.form, Property, Object somewhere down the aquisition path or even local loop and dtml-with namespaces. information from DTML Documents to DTML Methods and vice versa (and maybe from DTML Methods to DTML Methods) without using the REQUEST object. *shiver* You need to have a good portion of masochism to work with that ;) But you can call DTML with DTML too. (dtml-call, dtml-var, dtml-whatever - all can call other dtml or python script methods) dtml-return is able to return abitrary objects too. But as said, its no fun to code like that. You can even call Python scripts in DTML (and vice versa) and keep the logic of your application out of the template. Later you can decide if you want to replace the DTML templates with ZPT templates. In short, if you dont do application logic with it, even DTML is kinda acceptable. (That said: no call, set, etc. in it) Regards Tino Wildenhain ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] (no subject)
I'm trying to get a handle on Zope and don't understand the rational behind the manage_changeProperties() method. Why, given an object called myObject with a title property, can I not change the title by saying simply: myObject.title='The new title' ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] (no subject)
On 18 Jul 2006 19:12:54 -, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Why, given an object called myObject with a title property, can I not change the title by saying simply: myObject.title='The new title' You can. Property sheets are aimed at ease of changing through the web; it is a simple schema for simple properties. -- Martijn Pieters ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Script execute with every request
Hi, Id like to log certain parts of each request into a database table for every request to provide an audit trail. I thought of inserting a dtml-call xxx into the standard_html_header, but when there is a RESPONSE.redirect, it will not be the original request that gets logged. Can anyone offer any suggestions? Thanks, Josh -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.10.1/391 - Release Date: 18/07/2006 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Script execute with every request
Joshua Burvill wrote: Hi, I’d like to log certain parts of each request into a database table for every request to provide an audit trail. I thought of inserting a dtml-call xxx into the standard_html_header, but when there is a RESPONSE.redirect, it will not be the original request that gets logged. Can anyone offer any suggestions? Thanks, Josh Dieter wrote this http://www.dieter.handshake.de/pyprojects/zope/emulateRedirect.py Maybe that helps. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] cant log in as admin
zope-2.8.8 freebsd-4.11 okay I've followed the directions on the zope website, in the PDF, and the Zope/doc docs. Could not really find the proper cure. Then I made an instance and placed it in /usr/local/www/Zope Started zope and the username and password does not work. there is an entry in Z2.log everytime I go to the link and everytime What am I doing wrong? the Zope/inituser is where I thought things should authenticate? Anyways I must really be missing something. cheers, Noah ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] cant log in as admin
Noah wrote: zope-2.8.8 freebsd-4.11 okay I've followed the directions on the zope website, in the PDF, and the Zope/doc docs. Could not really find the proper cure. Then I made an instance and placed it in /usr/local/www/Zope Started zope and the username and password does not work. there is an entry in Z2.log everytime I go to the link and everytime What am I doing wrong? the Zope/inituser is where I thought things should authenticate? Anyways I must really be missing something. cheers, Noah You tried this? http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/Security.stx See the section on emergency user. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )