Re: [Zope] TAL/SQL Problem

2005-04-07 Thread Barry Pederson
Phil Beardmore wrote:
 Hi, hope you can help.
 
 We are currently linking a webpage to an SQL database and are pulling in
 information via the tal:replace function.  This is working extremely
 well however one of our SQL fields is comma deliminated, and we want it
 to appear as a list.  We have accomplished this by using the following
 code:
 
 h1Interests/h1
 
 tal:x define=test2 result/interests
   repeat=id python:interests.split(',')
  pa href=
 tal:attributes=href string:detail_html?id=$id
 tal:content=result/interests
Interests goes here/a/p
 /tal:x
 
 This works well, and each item of text is displayed as a list item. 
 Only problem we have, is we want to be able to display the SQL text as
 the link name, but instead each link has the same link text which is the
 whole of the SQL string.
 
 E.g.  The text in the interests field is:  Swimming,Badminton,Ice Hockey
 detail_html?id=Swimming
 
 The code seperates the text via the comma, and displays a list item for
 each activity.  Only problem is, the link text for each activity is the
 same (Swimming,Badminton,Ice Hockey detail_html?id=Swimming).  Anyone
 got any ideas?
 
 Hope you can understand what I am after.  An example page is at:
 
 http://lash.sunderland.ac.uk/business/organisationandstaff/test/detail_html?id=10
 
 
 Thanks
 Phil

In the a tag, instead of

 tal:content=result/interests

shouldn't it be

 tal:content=id

---

Barry
___
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] Problem with Z Psycopg

2005-04-06 Thread Barry Pederson
Jeff Gentry wrote:
 On Tue, 5 Apr 2005, Dieter Maurer wrote:
Usually, this means that the postgres server process died...
 
 I did run into something recently where the local firewall was killing the
 connection to the DB server due to a timeout, so one of the local admin
 types wrote a small zsql method that gets hit by a cronjob about once an
 hour or so.
 
 Granted the end effect is the same (zope thinks that the DB server has
 died) but in this case it was the connection itself.

Yeah, I think Jeff nailed it.  I had FreeBSD's IPFilter set to drop idle states
after an hour.  Turns out FBSD by default does TCP keepalive, but only after 2
idle hours.  I changed the net.inet.tcp.keepidle sysctl to lower it to a
half-hour, so it now gooses the firewall often enough that I haven't seen a
dropped connection since then.

Looking back at the pgsql logs, I think I've always had this problem, but just
didn't realize it until I tried a new ZPsycopgDA that lacked the auto-reconnect
feature.

Even though tweaking TCP fixed the problem, I think it'd still be good if
ZPsycopgDA was able to auto-reconnect, because you could lose connections for
other reasons - such as restarting postgres - and it'd be nice to not have to go
and restart Zope too.

(I think it's kind of funny that I didn't find out about my TCP problem until
ZPsycopgDA failed to auto-reconnect, and I wouldn't have found out so soon about
ZPsycopgDA not auto-reconnecting if I didn't have the TCP problem :)

Barry
___
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] Problem with Z Psycopg

2005-04-05 Thread Barry Pederson
Jason Leach wrote:
 I'm having a problem with Z Psycopg.  From time to time (quite often)
 it looses the connection with the database and I get:
Site Error
An error was encountered while publishing this resource.
Error Type: OperationalError
Error Value: no connection to the server

Garth B. wrote:
 I have the same problem, but I eventually corrected it, by forcibly
 closing the connection each time prior to running the queries.
 Fortunately, my scenario uses page caching to reduce the number of hits
 to the db so the additional effort of reopening the connection is neglible.

 I'd sure like to know what the problem is, though...


I've been looking at the differences between ZPsycopg that comes with 1.0.x and
1.1.x, and it looks like the older ZPsycopg had code to automatically reconnect
on an OperationalError (in db.py, the DB.query() method), but the corresponding
method in the newer ZPsycopg doesn't have that.  Looks like it was removed in
1.1.11 or 1.1.12

I'm trying this patch to see if it gets back the reliability my old setup had -
although I'm not sure what other bad stuff this could cause

--

--- db.py.original  Fri Oct 29 19:19:27 2004
+++ db.py   Tue Apr  5 12:56:46 2005
@@ -222,7 +222,12 @@
 result = c.fetchall()
 desc = c.description
 self.failures = 0
-
+
+except psycopg.OperationalError, err:
+if hasattr(self, 'db'):
+del c; del self.db
+return self.query(query_string, max_rows, query_data)
+
 except StandardError, err:
 self._abort()
 raise err

--

Barry
___
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] Problem with Z Psycopg

2005-04-05 Thread Barry Pederson
Dieter Maurer wrote:
 Jason Leach wrote at 2005-4-4 15:15 -0700:
 
I'm having a problem with Z Psycopg.  From time to time (quite often)
it looses the connection with the database and I get:
  Site Error
  An error was encountered while publishing this resource.
  Error Type: OperationalError
  Error Value: no connection to the server
 
 
 Usually, this means that the postgres server process died...

I checked my pgsql logs, and it seemed like the zope connection was dying first,
and then later on pgsql showed an unexpected EOF.  So I don't think it's the
postgres server dying first.


Then I have to login then close and open the connection.  It then
works for a while before bailing again.
 
 
 I do not have to do this because ZPsycopgDA automatically
 reconnects when an OperationalError is raised.
 Thus, this is strange.

Like I mentioned in another post - it looks like that feature was removed in the
ZpsycopgDA that comes with psycopg 1.1.11 or 1.1.12  I've tried patching the
auto-reconnect back in, and so far so good.  Looks like a couple connections
recently died, but the site is still going OK.

Barry
___
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] Problem with Z Psycopg

2005-04-04 Thread Barry Pederson
Jason Leach wrote:
I'm having a problem with Z Psycopg.  From time to time (quite often)
it looses the connection with the database and I get:
   Site Error
   An error was encountered while publishing this resource.
   Error Type: OperationalError
   Error Value: no connection to the server
Then I have to login then close and open the connection.  It then
works for a while before bailing again.
Does anyone know what would be causing this?
Zope Version (Zope 2.7.3-0, python 2.3.4, linux2)
Python Version 2.3.4 (#1, Oct 13 2004, 21:44:19) [GCC 2.95.4 20011002
(Debian prerelease)]
And ZPsycopg is version 1.11
Not sure, but I can report seeing the same thing on a different setup
FreeBSD 4.8
Zope 2.7.5
Python 2.3.5
psycopg 1.1.18 (linked to PostgreSQL 8.0.1 client library)
(PostgreSQL server is also 8.0.1, but on FreeBSD 5.2.1)
On the very same machine I also have
Zope 2.6.1
Python 2.1.3
psysopg 1.0.6 (linked to an older PostgreSQL 7.2 client library)
running simultaneously, connecting to the very same DBs, but it hasn't 
had the same connection problems.

I was wondering if it might be something with psycopg and the new pgsql 
8.0.1 library.  What pgsql client lib is you psycopg linked to?

	Barry
___
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-dev] SMPT Authorization support

2003-12-11 Thread Barry Pederson
Lennart Regebro wrote:
I just checked in (on regebro-esmpt_support-branch) support for setting a
username and password on the mailhost. Very nice and easy fix, and lot's of
people want it.
But I realized that what you actually might want is to have different login
and password for each user, that is a possibility to pass username +
password to send(). And maybe you want a setting to allow this or not.
Or is this overkill? What do you think?

(This is for all for 2.8, obviously).
Yeah, I think that could be handy - especially where you have zope and your 
smtp-server authenticating off the same source (ldap?).  Then if there was a 
question as to who sent a mail, you'd only have to look in the mail logs, and 
not try and cross-reference them with web logs.

Maybe have it so it uses the userid+password if it's available, or a 
specified id/password when it's an anonymous user.

	Barry

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] debugging memory leaks

2003-10-28 Thread Barry Pederson
Seb Bacon wrote:

So, say Foo is leaking because it is referenced from O which can't be 
collected.  Given 100 things which refer to Foo, how do I identify which 
one is O?  And of course, then O may be leaking because it is referenced 
from P...
I've been looking into memory leaks of my own, and put together a small 
module that outputs the information available from the gc.garbage list in a 
format that Graphviz (http://www.research.att.com/sw/tools/graphviz/) can 
then render as an image (GIF, SVG, etc) that makes it a bit easier to see the 
cycles.

Here's a sample image:

   http://barryp.org/misc/simpletal_visualize/test2.gif

Here's the code

http://barryp.org/misc/simpletal_visualize/visualize_pyobjects.py

It shouldn't be too hard to use that in your own code, something like:

  import visualize_pyobjects
  gc.collect()
  cycles = visualize_pyobjects.prune_stems(gc.garbage)
  visualize_pyobjects.create_dot(cycles, '/tmp/foo.dot')
and then, run the graphviz 'dot' program from the command line to create a 
GIF file:

  dot -Tgif /tmp/foo.dot /tmp/foo.gif

(use a '-Tsvg' option to create an SVG file, which is smaller and easily 
viewed and edited with things like sodipodi I believe)

	Barry



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Python core dump zope 2.6.1+CMF1.3

2003-02-11 Thread Barry Pederson
R. David Murray wrote:

I haven't touched Z2 in a while.  But I need a Plone site (I think).
So I downloaded 2.6.1, CMF1.3, and Plone 1.0.  Installed all on
FreeBSD 4.7.  Created a plone portal.  Going to the plone site URL
causes a python core dump.  Created a plain CMF site.  Going to the
site URL causes a python core dump.  Going to the /manage version
of the same URL works fine, by the way.

Others have seen this, so it should be easy for Concerned Parties
to reproduce this.  I have to run off to a meeting so I can't do
any more deubgging on this tonight.  NB: python 2.2.2 also core
dumps under the same scenario.


Sounds like you need the THREAD_STACKS_SIZE patch for FreeBSD's Python 2.1

http://sourceforge.net/tracker/?func=detailatid=305470aid=554841group_id=5470

There's a download link near the bottom of the page.

Basically put that patch in your /usr/ports/lang/python2.1/files directory, 
then re-build the Python 2.1 port with -DTHREAD_STACK_SIZE=0x2 
specified as an argument to the make command.

* OR **

If you've cvsup-ed your ports tree lately, there may already be a patch in 
place in that same directory named patch-Python-thread_pthread.h-stacksize 
that looks like it does basically the same thing.

However I haven't tried it, I built my Python 2.1 + Zope 2.6.0 + Plone setup 
before that was added to the port. The first patch from sourceforge did the 
trick for curing crashes in my case, so I'd guess that an updated port and a 
re-built Python 2.1 might be the ticket in your case.

	Barry


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] StructuredText with Images

2002-05-22 Thread Barry Pederson

I posted this earlier on zope, but I guess maybe it's more of a zope-dev kind 
of thing

-
I was wondering what's the story with 
lib/python/StructuredText/HTMLWithImages.py - it looks like it should allow 
you to place images in structured text, with something like:

  my image:img:http://foo.com/myimg.jpg

but it doesn't seem to be used by default, instead plain HTMLClass.py looks 
to be the usual handler for STX documents, for example when calling 
structured_text() from within a PythonScript.

I'm also curious why HTMLWithImages.document() method overrides 
HTMLClass.document() but takes away the option of disabling the header, and 
only adds a: bgcolor=#FF attribute to the body tag (athough the version 
in CVS doesn't even add that).

In CVS it also looks like HTMLWithImages overrides the HTMLClass.xref() 
method with an absolutely identical method.

I'm guessing I could call it with an external method (I'm not asking for help 
with that) - I would mostly like to know why is it (HTMLWithImages) there 
separately, why isn't it being used by default, and why is it just a little 
different from HTMLClass in not being able to turn off the headers in the 
document() method.

 Barry




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] WebDAV quibble -- fix in 2.6?

2002-03-06 Thread Barry Pederson

Casey Duncan wrote:
 This maybe more 2.6 (or even 2.5.1 final) fodder:
 
 I notice that in a vanilla Zope install, Anonymous users are allowed access 
 through WebDAV. This is bad for two reasons:
 
 1. From a security perspective this discloses way too much information about 
 your site to the outside world.
 
 2. Due to vagarities of WebDAV authentication, it makes it impossible to edit 
 anything, because I guess the WebDAV implementation is too stupid to force a 
 login when you try to lock something as anonymous (instead is returns a 500 
 server error). To get around this you have to create or copy an object to 
 force a login. This problem disappears if everyone must login to access 
 WebDAV at all.
 
 So the question is: Is there a good reason why WebDAV access is granted to 
 anonymous by default? If not I vote we change it.


Agreed, the way it is now is just wrong, and I was shocked to see it 
wide-open like that.

Barry


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope] Uninstall on WinNT and the Registry

2000-06-23 Thread Barry Pederson

I was just uninstalling Zope 2.2b1 from a WinNT box, and selected the custom
uninstall to see what all it was taking out - and when it got to the part
about removing registry keys, it showed some things that looked pretty dodgy..

The dialog box legend says: "The following Registration Database Keys were
created during the installation. Select those keys that you want to remove."

And then goes on to list quite a few Zope-related things that sound ok, but
also lists:

  SYSTEM
  SYSTEM\CurrentControlSet
  SYSTEM\CurrentControlSet\Services

That can't be right.  If the uninstall really did blow away those parts of the
registry tree..you'd be screwed.  What's going on here?

Barry

___
Zope maillist  -  [EMAIL PROTECTED]
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 )