[Zope-Checkins] SVN: Zope/trunk/lib/python/Zope.py Put warning on a single line.

2005-07-27 Thread Florent Guillaume
Log message for revision 37481:
  Put warning on a single line.
  

Changed:
  U   Zope/trunk/lib/python/Zope.py

-=-
Modified: Zope/trunk/lib/python/Zope.py
===
--- Zope/trunk/lib/python/Zope.py   2005-07-27 13:38:39 UTC (rev 37480)
+++ Zope/trunk/lib/python/Zope.py   2005-07-27 13:56:04 UTC (rev 37481)
@@ -20,8 +20,7 @@
 sys.modules['Zope'] = Zope2
 
 import warnings
-warnings.warn(The Zope package has been renamed to Zope2.\n
-  Import of a package named 'Zope' is deprecated\n
-  and will be disabled starting in Zope 2.11.\n
-  ,
+warnings.warn(The Zope package has been renamed to Zope2. 
+  Import of a package named 'Zope' is deprecated 
+  and will be disabled starting in Zope 2.11.,
   DeprecationWarning, stacklevel=2)

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/lib/python/Zope.py Put warning on a single line.

2005-07-27 Thread Florent Guillaume
Log message for revision 37482:
  Put warning on a single line.
  

Changed:
  U   Zope/branches/Zope-2_8-branch/lib/python/Zope.py

-=-
Modified: Zope/branches/Zope-2_8-branch/lib/python/Zope.py
===
--- Zope/branches/Zope-2_8-branch/lib/python/Zope.py2005-07-27 13:56:04 UTC 
(rev 37481)
+++ Zope/branches/Zope-2_8-branch/lib/python/Zope.py2005-07-27 13:58:22 UTC 
(rev 37482)
@@ -20,8 +20,7 @@
 sys.modules['Zope'] = Zope2
 
 import warnings
-warnings.warn(The Zope package has been renamed to Zope2.\n
-  Import of a package named 'Zope' is deprecated\n
-  and will be disabled starting in Zope 2.11.\n
-  ,
+warnings.warn(The Zope package has been renamed to Zope2. 
+  Import of a package named 'Zope' is deprecated 
+  and will be disabled starting in Zope 2.11.,
   DeprecationWarning, stacklevel=2)

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope] product organization

2005-07-27 Thread Nicholas Wieland
As usual, my question is rather simple :)
I'd like to know what are the best practices for product organization - for example I have _tons_ of queries to sqlserver, and my main class is becoming less manageble every time I look at it :/
I like the way SQL integrates in Zope, what I don't like is having a giant __init__ and a lot of _sqlSomething at the end of the class.

Can I associate queries to something else than a _variable ? Something like a dictionary or a class ? Can I move SQL calls outside the initializer ? I'd prefer to have a class for data access andanother one to glue all the parts together, maybe I'm plain wrong but I think that my product would bea lot cleaner.
What are the best practices for FS based products ?
		Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3___
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] product organization

2005-07-27 Thread Marco Bizzarri
Nicholas Wieland wrote:
 As usual, my question is rather simple :)
 I'd like to know what are the best practices for product organization -
 for example I have _tons_ of queries to sqlserver, and my main class is
 becoming less manageble every time I look at it :/
 I like the way SQL integrates in Zope, what I don't like is having a
 giant __init__ and a lot of _sqlSomething at the end of the class.
  
 Can I associate queries to something else than a _variable ? Something
 like a dictionary or a class ? Can I move SQL calls outside the
 initializer ? I'd prefer to have a class for data access and another one
 to glue all the parts together, maybe I'm plain wrong but I think that
 my product would be a lot cleaner.
 What are the best practices for FS based products ? 
 
 
 *Yahoo! Mail*
 http://us.rd.yahoo.com/mail_it/taglines/*http://it.mail.yahoo.com:
 gratis 1GB per i messaggi, antispam, antivirus, POP3
 
 
 
 
 ___
 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 )

I can't talk for best practise. You can put your queries also outside of
the init, in this way:

class YourProduct:

_my_query = SQL('doMyQuery', '',
'your_connection', '', 'select * from data')

def __init__(self):
pass


Also, if you have a *LOT* of queries, consider in building your query on
the fly.

Regards
Marco
begin:vcard
fn:Marco Bizzarri
n:Bizzarri;Marco
org:Icube S.r.l.
adr:;;via Ridolfi 15;Pisa;PI;56124;Italy
email;internet:[EMAIL PROTECTED]
title:Amministratore Delegato
tel;work:+39-050-970-207
tel;fax:+39-050-3136-588
tel;cell:+39-348-640-4861
x-mozilla-html:FALSE
url:http://notenotturne.blogspot.com/
version:2.1
end:vcard

___
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] unwise.exe missing on linux

2005-07-27 Thread michael nt milne
Hi

Does anyone know if the zope uninstall program 'unwise.exe' can be got
separately? I have installed zope on linux but the unwise.exe program
isn't within the package.

Thanks

Michael
___
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] ZPsycopg - Losing Connections

2005-07-27 Thread David
Python 2.3.5 - Zope 2.7.5 - PostgreSQL 7.3.4 - Psycopg 1.1.18 -  
Solaris 8 (Intel)


Hi

I am experiencing a new problem, that was not present in the past on  
the above server. From the Zope error log:


Exception Type  OperationalError
Exception ValuePQsendQuery() -- There is no connection to the  
backend.

Traceback (innermost last):

Module ZPublisher.Publish, line 92, in publish
Module ZPublisher.BaseRequest, line 433, in traverse
Module Products.exUserFolder.exUserFolder, line 869, in validate
Module Products.exUserFolder.exUserFolder, line 1133, in listOneUser
Module Products.exUserFolder.pgAuthSource.pgAuthSource, line 244, in  
listOneUser

Module Shared.DC.ZRDB.DA, line 454, in __call__
SQL instance at 922dd70
Module Products.ZPsycopgDA.db, line 228, in query
OperationalError: PQsendQuery() -- There is no connection to the  
backend.


When I check in psql, I can see a connection still being there.
Using the query:
SELECT count(pg_stat_activity.datname) AS count,  
pg_stat_activity.datname FROM pg_stat_activity GROUP BY  
pg_stat_activity.datname;

(Is this really showing active connections? Or just recent usage?)

If I use the close connection and then open connection buttons in the  
Z Psycopg Database Connection in Zope, I get the connection usually  
back. Sometimes I have to re-submit the properties to make it work,  
though.


Properties settings are:
Connect immediately is checked
Use Zope's internal DateTime module (instead of mxDateTime) is checked
Transaction isolation level:  Serializable
Backend encoding: UTF-8
Output Unicode strings is not checked

This is fast becoming a real headache for us!

What has changed? We have recently increased the max_connections and  
shared_buffers for PostgreSQL and now run more Zope instances with  
now averaging about 40 connections from the database (using the query  
above). So this is an increase.


Any help on how I can find out what's going on here is very welcome!  
(or in short: HELP, PLEASE!)


Cheers




___
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] unwise.exe missing on linux

2005-07-27 Thread Lennart Regebro
On 7/27/05, michael nt milne [EMAIL PROTECTED] wrote:
 Does anyone know if the zope uninstall program 'unwise.exe' can be got
 separately? I have installed zope on linux but the unwise.exe program
 isn't within the package.

That's because unwise.exe is only needed if you used wise to install
it. Which you only can if you are on windows.

On Unix you uninstall Zope by deleting the directory.
___
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] product organization

2005-07-27 Thread Nicholas Wieland

Well, not exactly - just a way to separate access to data from everything else in the product.
Maybe a separate class that needs the connection asargument and that just returns the data I need in appropriate data structures by calling class methods.

class DataModel (object):

 def __init__ (self, conn):
 self.conn = conn
 self.sqlFetchSomething = SQL (.)

 def fetchSomething (self):
 return self.sqlFetchSomething

This is really simple, but I think it gives the idea.
Obviously I'd like to perform various operation at the data level, for example return a list of lists for reportlab tables and so on.

TIA,
 ngw
		Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3___
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] Re: Running more than one instance on windows often block each other

2005-07-27 Thread Sune B. Woeller

I will try to recreate the problem on other
flavours of windows asap. I will get back to you
later.

I guess my reporting was a bit too quick, sorry:
I'm running python 2.3.5, (installed from windows binary).
Zope 2.7.7 (not necessary for the test scripts)
Windows XP Home SP2 (blush - my laptop came with that... ;) )

Sune


Tim Peters wrote:

[Sune Brøndum Wøller]


Thanks for the pointer. I have been debugging
select_trigger.py, and has some more info:

The problem is that the call a.accept() sometimes hangs.
Apparently a.bind(self.address) allows us to bind to
a port that another zope instance already is bound to.

The code creates the server socket a, and the client socket w,
and gets the client socket r by connecting w to a. Then it closes a.
a goes out of scope when __init__ terminates, and is probably garbage
collected at some point.



Unless you're using a very old Python, `a` is collected before the
call returns (where the call means the call of the function in which
`a` is a local variable).  Very old Pythons had an idiotic __del__
method attached to their Windows socket wrapper, which inhibited
timely gc.



I tried moving the code to the following standalone script, and I can reproduce
the error with that. In the original code w is kept as an instance variable, and
r is passed to asyncore.dispatcher.__init__  and probably kept there.



Yes, the socket bound to `r` also gets bound to `self.socket` by this call:

asyncore.dispatcher.__init__ (self, r)



I simulate that by returning them, then the caller of socktest can keep them
around.

I try to call socktest from different processes A and B (two pythons):
(w,r = socktest())
The call in A gets port 1. The second call, in B, either blocks, or takes
over port 1 (I see the second process taking over the port in a port 
scanner.)



Sorry, I can't reproduce this -- but you didn't give a test program,
just an isolated function, and I'm not sure what you did with it.  I
called that function in an infinite loop, appending the return value
to a global list, with a short ( 0.1 second) sleep between
iterations, and closed the returned sockets fifty iterations after
they were created.  Ran that loop in two processes.  No hangs, or any
other oddities, for some minutes.  It did _eventually_ hang-- and both
processes at the same time --with netstat showing more than 4000
sockets hanging around in TIME_WAIT state then.  I assume I bashed
into some internal Windows socket resource limit there, which Windows
didn't handle gracefully.  Attaching to the processes under the MSVC 6
debugger, they were hung inside the MS socket libraries.  Repeated
this several times (everything appeared to work fine until  4000
sockets were sitting in TIME_WAIT, and then both processes hung at
approximately the same time).

Concretely:

sofar = []
try:
while 1:
print '.',
stuff = socktest()  # calling your function
sofar.append(stuff)
time.sleep(random.random()/10)
if len(sofar) == 50:
tup = sofar.pop(0)
w, r = tup
msg = str(random.randrange(100))
w.send(msg)
msg2 = r.recv(100)
assert msg == msg2, (msg, msg2)
for s in tup:
s.close()
except KeyboardInterrupt:
for tup in sofar:
for s in tup:
s.close()

Note that there's also a bit of code there to verify that the
connected sockets can communicate correctly; the `assert` never
triggered.

You haven't said which versions of Windows or Python you're using.  I
was using XP Pro SP2 and Python 2.3.5.  Don't know whether either
matters.

It was certainly the case when I ran it that your



   print port



statement needed to display ports less than 1 at times, meaning that the



   a.bind((host, port))



did raise an exception at times.  It never printed a port number less
than 19997 for me.  Did you ever see it print a port number less than
1?



a.bind in B does not raise socket.error: (10048, 'Address already in use') as
expected, when the server socket in A is closed, even though the port is used by
the client socket r in A.



I'm not sure what that's saying, but could be it's an illusion.  For example,



import socket
s = socket.socket()
s.bind(('localhost', 1))
s.listen(2)
a1 = socket.socket()
a2 = socket.socket()
a1.connect(('localhost', 1))
a2.connect(('localhost', 1))
b1 = s.accept()
b2 = s.accept()
b1[0].getsockname()


('127.0.0.1', 1)


b2[0].getsockname()


('127.0.0.1', 1)


That is, it's normal for the `r` in



   r, addr = a.accept()



to repeat port numbers across multiple `accept()` calls, and indeed to
duplicate the port number from the `bind` call.  This always confused
me (from way back in my Unix days -- it's not a Windows thing), and
maybe it's not what you're talking about anyway.



If I remove a.close(), and keep a around (by passing it to the caller), a.bind
works as expected - it 

[Zope] Re: Running more than one instance on windows often block each other

2005-07-27 Thread Sune B. Woeller

I will try to recreate the problem on other
flavours of windows asap. I will get back to you
later.

I guess my reporting was a bit too quick, sorry:
I'm running python 2.3.5, (installed from windows binary).
Zope 2.7.7 (not necessary for the test scripts)
Windows XP Home SP2 (blush - my laptop came with that... ;) )

Sune


Tim Peters wrote:

[Sune Brøndum Wøller]


Thanks for the pointer. I have been debugging
select_trigger.py, and has some more info:

The problem is that the call a.accept() sometimes hangs.
Apparently a.bind(self.address) allows us to bind to
a port that another zope instance already is bound to.

The code creates the server socket a, and the client socket w,
and gets the client socket r by connecting w to a. Then it closes a.
a goes out of scope when __init__ terminates, and is probably garbage
collected at some point.



Unless you're using a very old Python, `a` is collected before the
call returns (where the call means the call of the function in which
`a` is a local variable).  Very old Pythons had an idiotic __del__
method attached to their Windows socket wrapper, which inhibited
timely gc.



I tried moving the code to the following standalone script, and I can reproduce
the error with that. In the original code w is kept as an instance variable, and
r is passed to asyncore.dispatcher.__init__  and probably kept there.



Yes, the socket bound to `r` also gets bound to `self.socket` by this call:

asyncore.dispatcher.__init__ (self, r)



I simulate that by returning them, then the caller of socktest can keep them
around.

I try to call socktest from different processes A and B (two pythons):
(w,r = socktest())
The call in A gets port 1. The second call, in B, either blocks, or takes
over port 1 (I see the second process taking over the port in a port 
scanner.)



Sorry, I can't reproduce this -- but you didn't give a test program,
just an isolated function, and I'm not sure what you did with it.  I
called that function in an infinite loop, appending the return value
to a global list, with a short ( 0.1 second) sleep between
iterations, and closed the returned sockets fifty iterations after
they were created.  Ran that loop in two processes.  No hangs, or any
other oddities, for some minutes.  It did _eventually_ hang-- and both
processes at the same time --with netstat showing more than 4000
sockets hanging around in TIME_WAIT state then.  I assume I bashed
into some internal Windows socket resource limit there, which Windows
didn't handle gracefully.  Attaching to the processes under the MSVC 6
debugger, they were hung inside the MS socket libraries.  Repeated
this several times (everything appeared to work fine until  4000
sockets were sitting in TIME_WAIT, and then both processes hung at
approximately the same time).

Concretely:

sofar = []
try:
while 1:
print '.',
stuff = socktest()  # calling your function
sofar.append(stuff)
time.sleep(random.random()/10)
if len(sofar) == 50:
tup = sofar.pop(0)
w, r = tup
msg = str(random.randrange(100))
w.send(msg)
msg2 = r.recv(100)
assert msg == msg2, (msg, msg2)
for s in tup:
s.close()
except KeyboardInterrupt:
for tup in sofar:
for s in tup:
s.close()

Note that there's also a bit of code there to verify that the
connected sockets can communicate correctly; the `assert` never
triggered.

You haven't said which versions of Windows or Python you're using.  I
was using XP Pro SP2 and Python 2.3.5.  Don't know whether either
matters.

It was certainly the case when I ran it that your



   print port



statement needed to display ports less than 1 at times, meaning that the



   a.bind((host, port))



did raise an exception at times.  It never printed a port number less
than 19997 for me.  Did you ever see it print a port number less than
1?



a.bind in B does not raise socket.error: (10048, 'Address already in use') as
expected, when the server socket in A is closed, even though the port is used by
the client socket r in A.



I'm not sure what that's saying, but could be it's an illusion.  For example,



import socket
s = socket.socket()
s.bind(('localhost', 1))
s.listen(2)
a1 = socket.socket()
a2 = socket.socket()
a1.connect(('localhost', 1))
a2.connect(('localhost', 1))
b1 = s.accept()
b2 = s.accept()
b1[0].getsockname()


('127.0.0.1', 1)


b2[0].getsockname()


('127.0.0.1', 1)


That is, it's normal for the `r` in



   r, addr = a.accept()



to repeat port numbers across multiple `accept()` calls, and indeed to
duplicate the port number from the `bind` call.  This always confused
me (from way back in my Unix days -- it's not a Windows thing), and
maybe it's not what you're talking about anyway.



If I remove a.close(), and keep a around (by passing it to the caller), a.bind
works as expected - it 

Re: [Zope] ZPsycopg - Losing Connections

2005-07-27 Thread Peter Bengtsson
On 7/27/05, Fernando Lujan [EMAIL PROTECTED] wrote:
 On 7/27/05, David [EMAIL PROTECTED] wrote:
  Python 2.3.5 - Zope 2.7.5 - PostgreSQL 7.3.4 - Psycopg 1.1.18 -
  Solaris 8 (Intel)
 
 
 The Psycopg version 1.1.19 solves this problem. :)
 
The 1.1.19 version isn't in debian yet.
$ apt-get show python-psycopg 
shows only 1.1.18 :(


 --
 Fernando Lujan
 ___
 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] ZPsycopg - Losing Connections

2005-07-27 Thread Fernando Lujan
On 7/27/05, Peter Bengtsson [EMAIL PROTECTED] wrote:
 On 7/27/05, Fernando Lujan [EMAIL PROTECTED] wrote:
  On 7/27/05, David [EMAIL PROTECTED] wrote:
   Python 2.3.5 - Zope 2.7.5 - PostgreSQL 7.3.4 - Psycopg 1.1.18 -
   Solaris 8 (Intel)
  The Psycopg version 1.1.19 solves this problem. :)
 The 1.1.19 version isn't in debian yet.
 $ apt-get show python-psycopg
 shows only 1.1.18 :(

So, use the source... ;)

-- 
Fernando Lujan
___
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] reportlab and images

2005-07-27 Thread Nicholas Wieland
I know, I'm flooding the list ...
I use images inside my reports, so I have to open PIL-image objects inside my product.
Everything is fine, but I must use the full path, like /Zope-Instance/Products/foobar/image/blah.png, and this is a problem, because the product will have a different path when put in production.
My solution is to have a class variable to use, like:

 imagepath = "/Zope-Instance/.../image"

and then use that variable to build the path, but I think it's ugly.
How do you solve this problem and just use 'image/blah.png' just like ZPTs, knowing that all image files will be stored in an "image" subdirectory of the product ?

TIA,
 ngw
		Yahoo! Messenger: chiamate gratuite in tutto il mondo ___
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] ZPsycopg - Losing Connections

2005-07-27 Thread Thomas Olsen
On Wednesday den 27. July 2005 14:45, Peter Bengtsson wrote:
 On 7/27/05, Fernando Lujan [EMAIL PROTECTED] wrote:
  On 7/27/05, David [EMAIL PROTECTED] wrote:
   Python 2.3.5 - Zope 2.7.5 - PostgreSQL 7.3.4 - Psycopg 1.1.18 -
   Solaris 8 (Intel)
 
  The Psycopg version 1.1.19 solves this problem. :)

 The 1.1.19 version isn't in debian yet.
 $ apt-get show python-psycopg
 shows only 1.1.18 :(

#wget 
http://ftp.de.debian.org/debian/pool/main/p/psycopg/python-psycopg_1.1.19-1_i386.deb
#dpkg -i python-psycopg_1.1.19-1_i386.deb

-- 
Med venlig hilsen

Thomas Olsen
http://www.headnet.dk
___
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] Re: Running more than one instance on windows often block each other

2005-07-27 Thread Tim Peters
[Sune B. Woeller]
 I will try to recreate the problem on other
 flavours of windows asap. I will get back to you
 later.

Cool!  If you can, posting a self-contained program that demonstrates
the problem is the best way to make progress.

 I guess my reporting was a bit too quick, sorry:

Not at all -- you did excellent detective work here!  It's
appreciated.  The problem is that English descriptions are nearly
always ambiguous, especially when trying to explain something
complicated that other people haven't reported.  Posting a program
removes all that guesswork:  it reproduces the problem for other
people on other boxes, or it doesn't, and we learn something valuable
either way; if it does fail for others, then they can help investigate
_why_ it fails.  At the start, thoroughly demonstrating a problem
exists is more important than guessing at what might be needed to worm
around it.

 I'm running python 2.3.5, (installed from windows binary).
 Zope 2.7.7 (not necessary for the test scripts)
 Windows XP Home SP2 (blush - my laptop came with that... ;) )

Good -- thanks.  A pretty vanilla system, then.  I've heard that XP
Home has special limitations on network capabilities, but don't know
more than that; it's at least possible they're relevant.  I'm not sure
that running multiple Zope instances on a laptop is a prime use case
for Zope wink.
___
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] find a file's type

2005-07-27 Thread Allen Huang
is there any dtml codes that can display a file's type?

I made a site that allows a person to send up a document file. But in the end what I really wanted is to let people to upload .doc files. 
Since I didn't put any restriction on it, people always send up a smaller .pdf file instead.

So how do I encode my webpage to show the file type of the file that have already being uploaded??
		 Start your day with Yahoo! - make it your home page ___
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] find a file's type

2005-07-27 Thread Peter Bengtsson
All File objects have a content_type property.
Try 
dtml-var _['somefile.doc'].content_type

On 7/27/05, Allen Huang [EMAIL PROTECTED] wrote:
 is there any dtml codes that can display a file's type? 
   
 I made a site that allows a person to send up a document file. But in the
 end what I really wanted is to let people to upload .doc files. 
 Since I didn't put any restriction on it, people always send up a smaller
 .pdf file instead. 
   
 So how do I encode my webpage to show the file type of the file that have
 already being uploaded??
 
  
  Start your day with Yahoo! - make it your home page 
 
 
 ___
 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 )


[Zope] use combined propertysheet variables to form a file name for a zObject

2005-07-27 Thread Allen Huang
I made a propertysheet for a customed zclass and I wish to use some variables and combine them to form a name for my newed created object.

Say I have variable 
a = 'name a'
b = 'value b'
c = 'string c'

what do I encode in my dtml method some_add 
 dtml-with "NewsClass.createInObjectManager(REQUEST['??'], REQUEST)"

?? into the combination of a, b, and c ?
		 Start your day with Yahoo! - make it your home page ___
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] use combined propertysheet variables to form a file name fora zObject

2005-07-27 Thread Jonathan



Here's a code snippet from one of our applications 
(you should be able to figure out what you need from this example):

 dtml-with 
UserData dtml-with 
"manage_addProduct['TCAide']" 
dtml-with "TCAUsers.createInObjectManager(REQUEST['clientid'], 
REQUEST)" 
dtml-call 
"propertysheets.TCAUsersPS.manage_changeProperties(REQUEST)" 
dtml-call reindex_object 
/dtml-with 
/dtml-with
UserData is a folder where new zclass instances are 
stored.
TCAUsers is our zclass
TCAUsersPS is the common instance propertysheet for 
the zclass
All of the property fields/values are stored in 
REQUEST (as a result of a user filling in an html form)
We call reindex_object because our zclasses are 
'catalog aware' and we are reindexing the catalog.

hth

Jonathan


  - Original Message - 
  From: 
  Allen Huang 

  To: zope@zope.org 
  Sent: Wednesday, July 27, 2005 12:07 
  PM
  Subject: [Zope] use combined 
  propertysheet variables to form a file name fora zObject
  
  I made a propertysheet for a customed zclass and I wish to use some 
  variables and combine them to form a name for my newed created object.
  
  Say I have variable 
  a = 'name a'
  b = 'value b'
  c = 'string c'
  
  what do I encode in my dtml method some_add 
   dtml-with 
  "NewsClass.createInObjectManager(REQUEST['??'], REQUEST)"
  
  ?? into the combination of a, b, and c ?
  
  
  Start 
  your day with Yahoo! - make it your home page 
  
  

  ___Zope maillist 
  - 
  Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** 
  No cross posts or HTML encoding! **(Related lists - 
  http://mail.zope.org/mailman/listinfo/zope-announcehttp://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] product organization

2005-07-27 Thread J Cameron Cooper

Nicholas Wieland wrote:


As usual, my question is rather simple :)
I'd like to know what are the best practices for product organization 
- for example I have _tons_ of queries to sqlserver, and my main 
class is becoming less manageble every time I look at it :/
I like the way SQL integrates in Zope, what I don't like is having a 
giant __init__ and a lot of _sqlSomething at the end of the class.
 
Can I associate queries to something else than a _variable ? 
Something like a dictionary or a class ? Can I move SQL calls outside 
the initializer ? I'd prefer to have a class for data access and 
another one to glue all the parts together, maybe I'm plain wrong but 
I think that my product would be a lot cleaner.
What are the best practices for FS based products ? 




If you're writing SQL queries attached to a Product and using them in 
said Product, you should look at ExtZSQL:


http://www.zope.org/Members/jccooper/extzsql

It was made for precisely this problem.

   --jcc


--
Building Websites with Plone
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.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 )


[Zope] what the namespace means in Script(python)?

2005-07-27 Thread Litao Wei

Hi list:

In Script(python) binding page. there is some description about 
namespace binding:


When the script is called from DTML, this is the caller's DTML 
namespace, otherwise it is an empty namespace.


Recommended value: |_| (underscore character)

But in zope book, when talk about  Error Handling in the Advanced Page 
Templates chapter. It looks that it use ZPT with script's namespace. See 
below.


For more flexible error handling you can call a script. For example:

div tal:on-error=structure here/handleError
...
/div

Any error that occurs inside the |div| will call the |handleError| 
script. Note that the |structure| option allows the script to return 
HTML. Your error handling script can examine the error and take various 
actions depending on the error. Your script gets access to the error 
through the |error| variable in the namespace. For example:


## Script (Python) handleError
##bind namespace=_
##
error=_['error']
if error.type==ZeroDivisionError:
   return pCan't divide by zero./p
else:
   return pAn error occurred./p
 pError type: %s/p
 pError value: %s/p % (error.type,
  error.value)



So what happened with namespace when calling Script from ZPT?

___
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] reportlab and images

2005-07-27 Thread Dieter Maurer
Nicholas Wieland wrote at 2005-7-27 15:47 +0200:
I use images inside my reports, so I have to open PIL-image objects inside my 
product.
Everything is fine, but I must use the full path, like 
/Zope-Instance/Products/foobar/image/blah.png, and this is a problem, because 
the product will have a different path when put in production.

Maybe, you should learn about package_home.

You find it in App.Common.

It is used in the form package_home(globals()) and
returns the directory the current module is located in (provided
this module lies in a Python package or is one).


-- 
Dieter
___
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] product organization

2005-07-27 Thread Dieter Maurer
Nicholas Wieland wrote at 2005-7-27 13:54 +0200:
Well, not exactly - just a way to separate access to data from everything else 
in the product.
Maybe a separate class that needs the connection as argument and that just 
returns the data I need in appropriate data structures by calling class 
methods.
 
class DataModel (object):
 
  def __init__ (self, conn):
self.conn = conn
self.sqlFetchSomething = SQL (.)

I think, a class variable sqlFetchSomething would do a better
job -- unless SQL depends on conn.

Advantages:

  *  fewer objects in the ZODB, fewer loads, faster operations

  *  easier evolution of your SQL (in you need to change the
 SQL executed)


-- 
Dieter
___
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] ZSQLMethod conditional insert

2005-07-27 Thread Thomas Olsen
Hi

This is probably an FAQ but I haven't been able to find and answer.

I need a counter for a certain CMFType and want to store the hits in a MySQL 
database not to fill up the ZODB. I've checked to two suggestions below but 
they both use two ZSQLMethods first to check if the URL is already in the 
table, then to do the actual update or insert.

http://www.zope.org/Members/element/Simple_SQL_Page_Counter
http://zopelabs.com/cookbook/991116439

I'd like to be able to do that just in one ZSQLMethod for efficiency but I 
cant seem to figure out a way of doing it.

The table is very simple:

CREATE TABLE mostread (
  path varchar(255) NOT NULL default '',
  num bigint(20) NOT NULL default '0',
  dt datetime NOT NULL default '-00-00 00:00:00',
  PRIMARY KEY  (path)
)

For now my ZSQLMethod get the argument path which is a relative URL and it 
looks like this:

  select @lastval:=num from mostread where dtml-sqltest path type=string
  dtml-var sql_delimiter
  update mostread set [EMAIL PROTECTED], dt=now() where dtml-sqltest path 
type=string;
  /dtml-if

But that naturally only works if there is already a record containing path. 
What I want to do is something like this (pseudo-code):

  select @lastval:=num from mostread where dtml-sqltest path type=string
  dtml-var sql_delimiter
  dtml-if sequence-length  0
update mostread set [EMAIL PROTECTED], dt=now() where dtml-sqltest path 
type=string;
  dtml-else
insert into mostread(path, num, dt)
  values(dtml-sqlvar path type=string, 1, now())
  /dtml-if

Is there a way of doing this or should I just create that extra ZSQLMethod?

-- 
Med venlig hilsen

Thomas Olsen
http://www.headnet.dk
___
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] Running more than one instance on windows often block each other

2005-07-27 Thread Tim Peters
[Tim Peters]
...
   Ran that loop in two processes.  No hangs, or any
 other oddities, for some minutes.  It did _eventually_ hang-- and both
 processes at the same time --with netstat showing more than 4000
 sockets hanging around in TIME_WAIT state then.  I assume I bashed
 into some internal Windows socket resource limit there, which Windows
 didn't handle gracefully.  Attaching to the processes under the MSVC 6
 debugger, they were hung inside the MS socket libraries.  Repeated
 this several times (everything appeared to work fine until  4000
 sockets were sitting in TIME_WAIT, and then both processes hung at
 approximately the same time).

More info on that:  since WinXP Pro supplies only about 4000 ephemeral
ports by default, and the program kept hanging after about 4000
ephemeral ports were in use (albeit most in their 4-minute TIME_WAIT
shutdown state), I tried boosting the # of ephemeral ports:

http://support.microsoft.com/kb/q196271

After that, I never saw the processes hang again.  BUT, I saw
something worse:  after about 20 minutes, both processes died with
assert errors, in the code I added to verify that the sockets were
communicating correctly.  The random string created in process A was
actually read by a socket in process B (instead of by its pair in
process A), and vice versa:  the random string created in process B
was read in process A, and at approximately the same time process B
was reading process A's string.

I tried it again, and got a pair of similar assert failures after
about 15 minutes.

That's dreadful, and I don't see how it could be anything except a
race bug in the Windows socket implementation.

The same program on Linux doesn't run long enough to say anything
interesting -- it raises BindError, 'Cannot bind trigger!' very
quickly every time, because it apparently keeps server port numbers
(1, 19998, ,,,) reserved for a long time after the server socket
is closed (where a long time just means longer than the few seconds
it takes for the program to die on Linux).

All of the above is wrt using socktest1() below.

socktest2() below contains the Windows code I already changed ZODB 3.4
to use.  I've been running socktest2() in two processes that way on
Windows for more than 2 hours now, with no glitches.  The same code is
running fine on a Linux box too.

So best guess now is that there is a subtle, rare error in the Windows
socket code that could cause the Medusa/ZODB3.2 Windows trigger code
to screw up.

Complete code:

import socket, errno
import time, random

class BindError(Exception):
pass


def socktest1():
blabla


address = ('127.9.9.9', 1)

a = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
w = socket.socket (socket.AF_INET, socket.SOCK_STREAM)

# set TCP_NODELAY to true to avoid buffering
w.setsockopt(socket.IPPROTO_TCP, 1, 1)

# tricky: get a pair of connected sockets
host='127.0.0.1'
port=1

while 1:
if port  1:
print port
try:
a.bind((host, port))
break
except:
if port = 19950:
raise BindError, 'Cannot bind trigger!'
port -= 1

a.listen (1)
w.setblocking (0)
try:
w.connect ((host, port))
except:
pass
r, addr = a.accept()
a.close()
w.setblocking (1)

#return (a, w, r)
return (r, w)
#return w

def socktest2():
a = socket.socket()
w = socket.socket()

# set TCP_NODELAY to true to avoid buffering
w.setsockopt(socket.IPPROTO_TCP, 1, 1)

# Specifying port 0 tells Windows to pick a port for us.
a.bind((127.0.0.1, 0))
connect_address = a.getsockname()  # assigned (host, port) pair
a.listen(1)
w.connect(connect_address)
r, addr = a.accept()  # r becomes asyncore's (self.)socket
a.close()

#return (a, w, r)
return (r, w)
#return w

sofar = []
try:
   while 1:
   print '.',
   stuff = socktest1()
   sofar.append(stuff)
   time.sleep(random.random()/10)
   if len(sofar) == 50:
   tup = sofar.pop(0)
   r, w = tup
   msg = str(random.randrange(100))
   w.send(msg)
   msg2 = r.recv(100)
   assert msg == msg2, (msg, msg2)
   for s in tup:
   s.close()
except KeyboardInterrupt:
   for tup in sofar:
   for s in tup:
   s.close()
___
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] Plone doesn't show up in the Zope Interface - ./runzope issue

2005-07-27 Thread michael nt milne
Hello

This is my first experience of unix installs from source and I need a
small amount of help to finish off my installation.

I've installed Zope and Python from source, remotely, onto a RedHat
box and am able to access the browser based ZMI admin screen remotely.
I've followed the following instructions for getting Plone up and
running but on stopping and starting the zope instance, Plone isn't
available. I've tried stopping the service using the ZMI and
restarting using telnet.

   1. Download Plone 2 from http://www.plone.org/download, and
select the tarball file.
   2. Unzip the archive using the following: tar xzf CMFPlone2.0.tar.gz
   3. You'll find that a directory has been created called
CMFPlone-xxx, where xxx is the version (for example, CMFPlone-2.0).
   4. Move the contents of that directory into your Zope
installation's Product directory. For example, if the Zope Products
directory is in /var/zope, then do this: mv CMFPlone2.0/
/var/zope/Products*

The zope products directory is /home/zopeinstance/Products/ which
lists Plone-2.0.5

I also have an issue where running /home/zopeinstance/bin/runzope

using ./runzope as the zopeinstance user

starts the service but the Unix prompt just hangs and doesn't do
anything. I am able to get the browser management screen but on
exiting the telnet session the service stops.

Would anyone have any ideas at all?

By the way ./start_zope
and ./stop_zope
from the core /zopeinstance directory don't seem to work.

Thanks for any help

Michael
___
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] Does Plone need the Zope CMF?

2005-07-27 Thread michael nt milne
Hi

This isn't clear to me. I've installed Zope and Python from source but
do I need to also install the Zope CMF for Plone to run properly? This
isn't mentioned specifically any where if so.

It would good to have some of these components wrapped up etc for
easier install. I couldn't find the RPM's on the site.

Michael
___
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] Does Plone need the Zope CMF?

2005-07-27 Thread Chris McDonough
Yes, it does (heavily).

See http://plone.org/documentation/how-to/setup-from-source


- C


On Wed, 2005-07-27 at 20:57 +0100, michael nt milne wrote:
 Hi
 
 This isn't clear to me. I've installed Zope and Python from source but
 do I need to also install the Zope CMF for Plone to run properly? This
 isn't mentioned specifically any where if so.
 
 It would good to have some of these components wrapped up etc for
 easier install. I couldn't find the RPM's on the site.
 
 Michael
 ___
 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] Does Plone need the Zope CMF?

2005-07-27 Thread Andreas Jung



--On 27. Juli 2005 20:57:23 +0100 michael nt milne 
[EMAIL PROTECTED] wrote:



Hi

This isn't clear to me. I've installed Zope and Python from source but
do I need to also install the Zope CMF for Plone to run properly? This
isn't mentioned specifically any where if so.




CMF is mandatory is  likely documented somewhere as requirement.

-aj


pgpq5uAiRda9o.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] Re: Zope Foundation Update

2005-07-27 Thread Christian Scholz
Hi!

Andrew Milton wrote:
 You took someone else's work and claimed it as your own. This is the worst 
 crime 
 you can commit in the Open Source world. 
 

I think it's not really a discussion about Open Source here as it should
make no difference to the Zope community whether ZC or ZEA is holding
the TM. Both don't represent it and both possibly could do harm to it if
they just wanted to (which they don't want as I see it).

I think it's more a story about a company which some time ago made their
software open source. The result of that was a big win for the Zope
project as it attracted a lot of developers and, as a result, created a
lot of additional projects like Silva, Plone, CPS etc. So now we have
quite a big community advocating the use of Zope and now also doing the
main development of the software itself (in form of Zope3).
I am part of that community and I am proud of that :-)
So from Zope having it's roots in that company these problems arise IMHO.

So having said that I am a bit disappointed by the recent discussions
here as it's maybe the sign of some unresolved problems between certain
important players in the Zope world.

Some points:

- How the thread was started by ZC was IMHO not really good style. For
  me it sounded like very hard words and threatening with not doing the
  foundation did not sound too good and not really a good thing for the
  community. I also still don't understand what the foundation has to do
  with the actual TM discussion - wasn't it just the logo about which
  was being discussed?
  So what would have happened in the case if not ZEA did register it but
  any evil guy?
  To hold the creation of the Foundation should not have been the answer
  in any case!

- if ZEA has registered the TM without telling ZC this is of course not
  ok. I understand if you don't discuss it loudly so that other parties
  hurry to register it but it could have been solved easily back then
  with a silent negotiation between the two parties.
  (too bad ZC did not simply register everything themselves so we would
  have one discussion less)

- in general: Bashing each other will not help Zope and not the
  community. And a damaged community cannot help ZC or ZEA or any other
  player in the Zope world. So it should be in everyones interest to
  keep things going in a good mood.


So that much about the form now more about my worries about the TM
itself. Legally of course ZC is the right owner of the TMs as they
created Zope. But OTOH it would feel more right if the TM would be
transferred to the Zope Foundation. ZC once opensourced their project
and the main work in terms of coding and marketing seems to be done by
the community now and less and less by ZC (at least it seems to
me that way). And for me Zope also feels like an open source project
through and through and not something belonging to some single company.
From what I see that's also the way most of the rest of the world thinks
about it, especially in Europe. Thus for me it would just feel better if
also the TM would be given to the community in form of the foundation
(as the community is no real legal person the foundation might be the
next possible thing).

I also read about the irrevocable license given to the Zope Foundation
and it might make no difference legally for the TM whether ZC or the ZF
owns it. But as said before, I am no legal expert and thus I don't know
about all the impacts and thus I am worried. So also because of this it
would feel better for me if the TM would be owned by the ZF as there are
just more checksbalances between their members than there will be with
a single player. And hopefully I would at least trust one of them ;-)

But maybe somebody can answer me some questions about it anyway:

1. What does the license mean. Does it mean that ZF will also have the
   right to decide who is allowed what to do with the TM, and even
   restrict ZC?

2. If ZC might get evil (I don't assume that, btw :-): What might happen
   with sites like zopelabs or any other site/institution having Zope
   in it's name. Can they tell them to remove that name?

3. What will happen in this worst case if ZC (or more exactly evil ZC)
   will suddenly start doing a Java CMS under the name Zope? Can the
   ZF prevent this?

So basically it's not quite clear to me if the license just means that
ZF is allowed to use the name or if they also can really protect it.
There might always be the possibility to rename the whole project but
why should I advocate Zope now if this investment might be lost someday?

So because of this discussion I am a bit worried. It might be called
irrational fears but I might not be the only one and as many in the
community are not fluent in legal things this stuff should be thought
about very carefully in order to keep the environment intact as this is
what Zope makes alive.
(OTOH the community seems not really taking part in that discussion so
maybe it's just me who is a bit worried ;-)

Finally I would 

Re: [Zope] ZSQLMethod conditional insert

2005-07-27 Thread David Pratt
Hi Thomas. I would say postgres is better for this sort of thing.  In 
postgres, you can write a function in plpgsql or other function 
language (there is also a python function language) that you install in 
postgres. In any case once you write it and then call it - it is 
executed in a single transaction.  You are only left with selecting the 
function in your zsql from your script. It is hard to comment on the 
method you have sketched out not knowing what arguments you are passing 
into the method. You have identified path but I see others that you 
haven't discussed so don't really know where you plan on getting them 
from.


Regards,
David


On Wednesday, July 27, 2005, at 03:22 PM, Thomas Olsen wrote:


Hi

This is probably an FAQ but I haven't been able to find and answer.

I need a counter for a certain CMFType and want to store the hits in a 
MySQL
database not to fill up the ZODB. I've checked to two suggestions 
below but
they both use two ZSQLMethods first to check if the URL is already in 
the

table, then to do the actual update or insert.

http://www.zope.org/Members/element/Simple_SQL_Page_Counter
http://zopelabs.com/cookbook/991116439

I'd like to be able to do that just in one ZSQLMethod for efficiency 
but I

cant seem to figure out a way of doing it.

The table is very simple:

CREATE TABLE mostread (
  path varchar(255) NOT NULL default '',
  num bigint(20) NOT NULL default '0',
  dt datetime NOT NULL default '-00-00 00:00:00',
  PRIMARY KEY  (path)
)

For now my ZSQLMethod get the argument path which is a relative URL 
and it

looks like this:

  select @lastval:=num from mostread where dtml-sqltest path 
type=string

  dtml-var sql_delimiter
  update mostread set [EMAIL PROTECTED], dt=now() where dtml-sqltest path
type=string;
  /dtml-if

But that naturally only works if there is already a record containing 
path.

What I want to do is something like this (pseudo-code):

  select @lastval:=num from mostread where dtml-sqltest path 
type=string

  dtml-var sql_delimiter
  dtml-if sequence-length  0
update mostread set [EMAIL PROTECTED], dt=now() where dtml-sqltest 
path

type=string;
  dtml-else
insert into mostread(path, num, dt)
  values(dtml-sqlvar path type=string, 1, now())
  /dtml-if

Is there a way of doing this or should I just create that extra 
ZSQLMethod?


--
Med venlig hilsen

Thomas Olsen
http://www.headnet.dk
___
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] ZSQLMethod conditional insert

2005-07-27 Thread Thomas Olsen
Hi David

On Wednesday den 27. July 2005 23:50, David Pratt wrote:
 Hi Thomas. I would say postgres is better for this sort of thing.  In
 postgres, you can write a function in plpgsql or other function
 language (there is also a python function language) that you install in
 postgres. In any case once you write it and then call it - it is
 executed in a single transaction.  You are only left with selecting the
 function in your zsql from your script. 

I would prefer postgres too but it is decided to use MySQL in the project...

 It is hard to comment on the 
 method you have sketched out not knowing what arguments you are passing
 into the method. You have identified path but I see others that you
 haven't discussed so don't really know where you plan on getting them
 from.

Well path is actually the only argument passed to the method. select 
@lastval:=num is a (I think) MySQL specific way of assigning values to local 
variables. I could probably use a sub-select or something but my SQL is a bit 
rusty ;-)

 Regards,
 David

 On Wednesday, July 27, 2005, at 03:22 PM, Thomas Olsen wrote:
  Hi
 
  This is probably an FAQ but I haven't been able to find and answer.
 
  I need a counter for a certain CMFType and want to store the hits in a
  MySQL
  database not to fill up the ZODB. I've checked to two suggestions
  below but
  they both use two ZSQLMethods first to check if the URL is already in
  the
  table, then to do the actual update or insert.
 
  http://www.zope.org/Members/element/Simple_SQL_Page_Counter
  http://zopelabs.com/cookbook/991116439
 
  I'd like to be able to do that just in one ZSQLMethod for efficiency
  but I
  cant seem to figure out a way of doing it.
 
  The table is very simple:
 
  CREATE TABLE mostread (
path varchar(255) NOT NULL default '',
num bigint(20) NOT NULL default '0',
dt datetime NOT NULL default '-00-00 00:00:00',
PRIMARY KEY  (path)
  )
 
  For now my ZSQLMethod get the argument path which is a relative URL
  and it
  looks like this:
 
select @lastval:=num from mostread where dtml-sqltest path
  type=string
dtml-var sql_delimiter
update mostread set [EMAIL PROTECTED], dt=now() where dtml-sqltest path
  type=string;
/dtml-if
 
  But that naturally only works if there is already a record containing
  path.
  What I want to do is something like this (pseudo-code):
 
select @lastval:=num from mostread where dtml-sqltest path
  type=string
dtml-var sql_delimiter
dtml-if sequence-length  0
  update mostread set [EMAIL PROTECTED], dt=now() where dtml-sqltest
  path
  type=string;
dtml-else
  insert into mostread(path, num, dt)
values(dtml-sqlvar path type=string, 1, now())
/dtml-if
 
  Is there a way of doing this or should I just create that extra
  ZSQLMethod?
 
  --
  Med venlig hilsen
 
  Thomas Olsen
  http://www.headnet.dk
  ___
  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 )

-- 
Med venlig hilsen

Thomas Olsen
http://www.headnet.dk
___
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] Re: ZSQLMethod conditional insert

2005-07-27 Thread Christian Scholz
Hi!

Might something like this help?

INSERT INTO table (a,b,c) VALUES (1,2,3)
   ON DUPLICATE KEY UPDATE c=c+1;

So this will catch errors and instead do the update.
Available from version 4.1.0 on as the docs say.

See also the docs:

http://dev.mysql.com/doc/mysql/en/insert.html

-- christian

PS: I might have misunderstood something ;-)


Thomas Olsen wrote:
 Hi
 
 This is probably an FAQ but I haven't been able to find and answer.
 
 I need a counter for a certain CMFType and want to store the hits in a MySQL 
 database not to fill up the ZODB. I've checked to two suggestions below but 
 they both use two ZSQLMethods first to check if the URL is already in the 
 table, then to do the actual update or insert.
 
 http://www.zope.org/Members/element/Simple_SQL_Page_Counter
 http://zopelabs.com/cookbook/991116439
 
 I'd like to be able to do that just in one ZSQLMethod for efficiency but I 
 cant seem to figure out a way of doing it.
 
 The table is very simple:
 
 CREATE TABLE mostread (
   path varchar(255) NOT NULL default '',
   num bigint(20) NOT NULL default '0',
   dt datetime NOT NULL default '-00-00 00:00:00',
   PRIMARY KEY  (path)
 )
 
 For now my ZSQLMethod get the argument path which is a relative URL and it 
 looks like this:
 
   select @lastval:=num from mostread where dtml-sqltest path type=string
   dtml-var sql_delimiter
   update mostread set [EMAIL PROTECTED], dt=now() where dtml-sqltest path 
 type=string;
   /dtml-if
 
 But that naturally only works if there is already a record containing path. 
 What I want to do is something like this (pseudo-code):
 
   select @lastval:=num from mostread where dtml-sqltest path type=string
   dtml-var sql_delimiter
   dtml-if sequence-length  0
 update mostread set [EMAIL PROTECTED], dt=now() where dtml-sqltest path 
 type=string;
   dtml-else
 insert into mostread(path, num, dt)
   values(dtml-sqlvar path type=string, 1, now())
   /dtml-if
 
 Is there a way of doing this or should I just create that extra ZSQLMethod?
 

___
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] ZPsycopg - Losing Connections

2005-07-27 Thread Felipe Barousse Boue
Fernando:

I have downloaded the source from 

   http://initd.org/pub/software/psycopg/PSYCOPG-1-1/

and compiled it (in RH FC4 and RHEL3, tough)  with no problams
whatsoever. 

I am using Zope 2.7.5, Python 2.3.5, Psycopg sources 1.1.19 and
PostgreSQL 8.0.3 

The only advice would be to upgrade your postgresql to 8.0.3 since the
version you are using is a bit outdated.

Best regards.

Felipe Barousse Boué
Piensa Technologies - Bufete Consultor de Mexico
www.piensa.com

On Wed, 2005-07-27 at 12:00 -0400, [EMAIL PROTECTED] wrote:
 Message: 15
 Date: Wed, 27 Jul 2005 13:45:52 +0100
 From: Peter Bengtsson [EMAIL PROTECTED]
 Subject: Re: [Zope] ZPsycopg - Losing Connections
 To: Fernando Lujan [EMAIL PROTECTED]
 Cc: zope@zope.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1
 
 On 7/27/05, Fernando Lujan [EMAIL PROTECTED] wrote:
  On 7/27/05, David [EMAIL PROTECTED] wrote:
   Python 2.3.5 - Zope 2.7.5 - PostgreSQL 7.3.4 - Psycopg 1.1.18 -
   Solaris 8 (Intel)
  
  
  The Psycopg version 1.1.19 solves this problem. :)
  
 The 1.1.19 version isn't in debian yet.
 $ apt-get show python-psycopg 
 shows only 1.1.18 :(

___
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] Re: ZSQLMethod conditional insert

2005-07-27 Thread Thomas Olsen
On Thursday den 28. July 2005 00:23, Christian Scholz wrote:
 INSERT INTO table (a,b,c) VALUES (1,2,3)
        ON DUPLICATE KEY UPDATE c=c+1;

Thanks - that was exactly what I needed

-- 
Med venlig hilsen

Thomas Olsen
http://www.headnet.dk
___
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] Re: Zope 2.8 Installation trouble on XP

2005-07-27 Thread Chris Beaven
Just to chirp in, I just tried to install 2.8 on my dev box and I am 
receiving the same error (XP SP2)


Previous versions of Zope that have been (and still are) installed: 
2.7.3, 2.7.5, 2.7.6


___
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] Re: Zope 2.8 Installation trouble on XP

2005-07-27 Thread Andreas Jung



--On 28. Juli 2005 13:59:54 +1200 Chris Beaven [EMAIL PROTECTED] 
wrote:



Just to chirp in, I just tried to install 2.8 on my dev box and I am
receiving the same error (XP SP2)



Could you please tell us *which error*? The people in charge for fixing 
such issues need some more useful information that the same error.


-aj


pgpWbfMcbjUKn.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 )


Re: [Zope] Running more than one instance on windows often block each other

2005-07-27 Thread Tim Peters
It's starting to look a lot like the Windows bind() implementation is
unreliable, sometimes (but rarely -- hard to provoke) allowing two
sockets to bind to the same (address, port) pair simultaneously,
instead of raising 'Address already in use' for one of them.  Disaster
ensues.

WRT the last version of the code I posted, on another XP Pro SP2
machine (again after playing registry games to boost the number of
ephemeral ports) I eventually saw all of:  hangs during accept(); the
assertion errors I mentioned last time; and mystery Connection
refused errors during connect().

The variant of the code below _only_ tries to use port 1.  If it
can't bind to that on the first try, socktest111() raises an exception
instead of trying again (or trying a different port number).  Ran two
processes.  After about 15 minutes, both died with assert errors at
about the same time (identical, so far as I could tell by eyeball):

Process A:

Traceback (most recent call last):
  File socktest.py, line 209, in ?
assert msg == msg2, (msg, msg2, r.getsockname(), w.getsockname())
AssertionError: ('292739', '821744', ('127.0.0.1', 1), ('127.0.0.1', 3845))

Process B:

Traceback (most recent call last):
  File socktest.py, line 209, in ?
assert msg == msg2, (msg, msg2, r.getsockname(), w.getsockname())
AssertionError: ('821744', '292739', ('127.0.0.1', 1), ('127.0.0.1', 3846))

So it's again the business where each process is recv'ing the random
string intended to be recv'ed by a socket in the other process. 
Hypothesized timeline:

process A's `a` binds to 1
process B's `a` binds to 1 -- according to me, this should be impossible
in the absence of SO_REUSEADDR (which acts very differently on
Windows than it does on Linux, BTW -- on Linux this should be impossible
even in the presence of SO_REUSEADDR; regardless, we're not using
SO_REUSEADDR here, and the braindead hard-coded

w.setsockopt(socket.IPPROTO_TCP, 1, 1)

is actually using the right magic constant for TCP_NODELAY on
Windows, as it intends).
A and B both listen()
A connect()s, and accidentally gets on B.a's accept queue
B connect()s, and accidentally gets on A.a's accept queue
the rest follows inexorably

Note that because this never tries a port number other than 1, it
can't be a bulletproof workaround simply to hold on to the `a` socket.
 If the hypothesized timeline above is right, bind() can't be trusted
on Windows in any situation where two processes may try to bind to the
same hostname:port pair at the same time.  Holding on to `a`, and
cycling through port numbers when bind() failed, would still
potentially leave two processes trying to bind to the same port number
simultaneously (just a port other than 1).

Ick:  this happens under Pythons 2.3.5 (MSVC 6) and 2.4.1 (MSVC 7.1),
so if it is -- as is looking more and more likely --an error in MS's
socket implementation, it isn't avoided by switching to a newer MS C
library.

Frankly, I don't see a sane way to worm around this -- it's difficult
for application code to worm around what smells like a missing
critical section in system code.

Using the simpler socket dance from the ZODB 3.4 code, I haven't yet
seen an instance of the assert failure, or a hang.  However, let two
processes run that long enough simultaneously, and it always (so far)
eventually fails with

socket.error: (10048, 'Address already in use')

in the w.connect() call, and despite that Windows picks the port numbers here!

While that also smells to heaven of a missing critical section in the
Windows socket implementation, an exception is much easier to live
with / worm around.  Alas, we don't have the MS source code, and I
don't have time to try disassembling / reverse-engineering the opcodes
(what EULA wink?), so best I can do is run this for many more hours
to try to increase confidence that an exception is the worst that can
occur under the ZODB 3.4 spelling.

Here's full code for the only try port 1 version:

import socket, errno
import time, random
def socktest111():
Raise an exception if we can't get 1.


a = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
w = socket.socket (socket.AF_INET, socket.SOCK_STREAM)

# set TCP_NODELAY to true to avoid buffering
w.setsockopt(socket.IPPROTO_TCP, 1, 1)

# tricky: get a pair of connected sockets
host = '127.0.0.1'
port = 1

try:
a.bind((host, port))
except:
raise RuntimeError
else:
print 'b',

a.listen (1)
w.setblocking (0)
try:
w.connect ((host, port))
except:
pass
print 'c',
r, addr = a.accept()
print 'a',
a.close()
print 'c',
w.setblocking (1)

return (r, w)

sofar = []
try:
   while 1:
   try:
   stuff = socktest111()
   except RuntimeError:
   print 'x',
   time.sleep(random.random()/10)
   continue
   sofar.append(stuff)