[Zope] Re: Defining a dictionary in ZPT?

2007-11-02 Thread Duncan Booth
"michael nt milne" <[EMAIL PROTECTED]> 
wrote:

>  tal:repeat="result python:query(id='IT')">
>First
> Name 
>  
> 
> but get this as a result. Thanks for the reply.
> 
> Module Products.PTProfiler.ProfilerPatch, line 32, in __patched_call__
> Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__
> - __traceback_info__: query(id='IT')
> Module Python expression "query(id='IT')", line 1, in 
> AttributeError: Results instance has no __call__ method

That is because you already called the function.

The tal:define="query here/testquery" is (roughly) equivalent to: 
tal:define="query python:here.testquery()". If you want to use a path 
expression which evaluates to something callable so that you have a shorter 
name later when you call it then you explicitly say you don't want to call 
it:

   tal:define="query nocall:here/testquery"

___
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: include?

2007-04-02 Thread Duncan Booth
"Katie" <[EMAIL PROTECTED]> wrote:

> We're almost finished getting the new site done completely in zope
> using css and mySql. We have an older portion of the old site done in
> php thought that we don't really want to re-write. We'd like to
> include it in the dtml document page that has all the common elements
> of every page but I'm at a loss of a way to do it other than using an
> inline frame. Is there a dtml include that takes a url string the way
> the  tag renders the associated file?
> 

Have a look at mxm Proxy tool:
http://www.mxm.dk/products/public/mxmProxyTool/

___
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: Isn't DTML more like what other frameworks do?

2007-01-08 Thread Duncan Booth
"Mark, Jonathan (Integic)"
<[EMAIL PROTECTED]> wrote: 

> So I don't really get the benefit of using ZPT. The fact that no one
> outside of Zope seems to have created a ZPT-like solution suggests to
> me that ZPT, as I said, solves a problem which doesn't exist. 

There are several applications outside Zope which use TAL and METAL as 
their templates: they didn't have to invent their own templating languages 
because Zope had already solved the problem for them.

N.B. These are separate implementations, not just borrowing of 
Zope code: modpython uses SimpleTAL, roundup I believe has its own 
implementation of TAL. There is also an implementation called OpenTAL 
although it looks kind of inactive.

It isn't just the Python world that uses TAL, there is also PHPTAL and 
there may be others that I didn't find.

___
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: Questions about demostorage

2006-12-15 Thread Duncan Booth
Chris Withers <[EMAIL PROTECTED]> wrote:
>> (So in other words, the 
>> connection from the demostorage front-end to the zeo-client isn't
>> frozen at the point when the storage is opened which might have been
>> a plausible alternative).
> 
> Urm, that would involve taking a complete copy of the db at open
> time... 

Not knowing the details of the implementation I don't know that it would. 
I'd have thought it would involve copying the index rather than the data, 
and since I don't know the implementation of the index it might only need 
to do a copy-on-write as and when parts of the index change.

> But really, what you're doing is not what DemoStorage was 
> designed for and will likely end in tears or a lot of hair pulling...

I know, that's why I'm trying to establish the boundaries of what I can 
expect from it.

>> What I'm hoping to achieve is a way of testing upgrades on our live
>> system in an environment as close as possible to the real live
>> environment, but without actually affecting the live system in any
>> way. Demostorage seems to offer that as an option.
> 
> It really doesn't ;-) Do this kinda testing the same way that everyone
> does: build yourself a uat environment that mirrors your production 
> environment, maybe with a few less zeo clients, run it off a copy of 
> your production zodb and then test there...

Got that, but the problem is that the test database isn't exactly identical 
to the live one (e.g. the ldap config points to the test ldap server) but 
I'm sure we could script the tweaks needed. More significantly is the pain 
involved in copying 10Gb from the live system onto dev on more than an 
occasional basis.

The problem I'm trying to address is that sometimes we make mistakes when 
updating the live server because of minor differences between the test and 
live environments. So on the live servers we have a separate zope instance 
for final testing. It has its own copy of the Products folder (checked out 
from the relevant svn tag) and when we are happy that the checkout works as 
expected I just rsync that Products folder onto the live Products.

I'm not suggesting running the system on demostorage for long periods of 
time. Simply long enough to check that whatever weird buildout changes we 
make are doing are going to work. That means that the only guarantee I 
really need is that the live system won't be affected by any changes to the 
test system; if the test system becomes internally inconsistent and falls 
over I'll just restart it and try again.

For example, we are currently running with an ancient svn checkout of 
CacheFu. I know, from playing on the dev system, that migrating from that 
to [a slightly patched copy of] the current version is possible, but it 
took some time and caused site errors until it was complete. I have a 
script which I believe should do the migration quickly but I want to be 
absolutely positive it is going to work without any hitches. If I can do a 
dry run in the live environment then I should be able to get that 
confidence.

___
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] Questions about demostorage

2006-12-14 Thread Duncan Booth
Can someone explain to me what is and is not safe to do with demostorage?

Say I have a zope setup involving a zeo server and clients, and I create 
another zope instance with  wrapped around both  
mounts (the catalogs are mounted separately from the rest of the content).
The main zope setup remains active while I'm using the demostorage setup, 
so content will be added/edited or deleted in the zeo zodb.

A bit of experimenting seems to indicate if I edit an object in the main 
system, the demostorage version picks up the changes until such time as I 
edit the same object in the demostorage instance. (So in other words, the 
connection from the demostorage front-end to the zeo-client isn't frozen at 
the point when the storage is opened which might have been a plausible 
alternative).

What I'm a little worried about is the catalog. I'd guess that there is no 
guarantee that the demostorage instance gets a catalog which is consistent 
with the rest of the data (so I could easily get site errors in the 
demostorage instance), but there should be no danger that any changes I 
make can affect the live site and restarting the demo instance would get it 
back into a consistent state, at least for a while. Is that a reasonable 
interpretation?

What I'm hoping to achieve is a way of testing upgrades on our live system 
in an environment as close as possible to the real live environment, but 
without actually affecting the live system in any way. Demostorage seems to 
offer that as an option.

___
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: How can I import python script into another python script?

2006-09-01 Thread Duncan Booth
Gabriel Genellina wrote:

> At Thursday 31/8/2006 18:11, Ferhat Ayaz wrote:
> 
>>I have a Script (Python) called 'functions'.
>>I want to import this script into another Script
>>(Python).
>>
>>import Include.Functions.requests
>>
>>says
>>
>>import of "Include.Functions.requests" is unauthorized
> 
> You don't import it; you can reference it as 
> container.Include.Functions.whatever(args...)
> 

Or even do:

Functions = container.Include.Functions

and then reference:

Functions.whatever()

But do yourself a favour and extract the functions out of your Python 
script into a Python module. It will run faster and be easier to maintain 
and to debug.

___
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: Packing Data.fs

2006-08-30 Thread Duncan Booth
Tres Seaver wrote:

> Mark Gibson wrote:
>> I know zope makes a copy of Data.fs before packing.  Is it possible to
>> specify a location other than /var to place that copy?
> 
> Actually, it makes a *new* file when packing, and then unlinks the old
> file and re-links the copy under its name after finishing the pack
> successfully.  If you are looking to "spread the love" across multiple
> partitions, you can symlink the original file into a directory on
> another drive / partition, and then do the pack there.  One the pack
> completes, you can move or copy the packed version back to the original
> directory.
> 
I recently had to move a fairly large Data.fs onto a different partition, 
but just copying it would have involved downtime (at least for 
authoring) that I wanted to avoid. 

The solution I came up with was to create a var folder on the new partition 
symlinking back to Data.fs in the original location. Then I switched ZEO to 
using the var on the new partition and packed the database. After packing 
the database was on the new partition with no downtime apart from a single 
ZEO restart.

___
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.9 Product Refreshing

2006-08-07 Thread Duncan Booth
Andreas Jung wrote:
> James Davies wrote:
>> Another major issue I've discovered is Zope hosting. We reguarly
>> deploy custom sites on shared zope environments, and having to
>> restart an entire server just to update one product severely breaks
>> our uptime guarentee. 
> 
> Refresh only works in debug-mode. You want to tell us that you are
> running a production site in debug-mode?

Since when does refresh only work in debug mode? Admittedly we are still on 
Zope 2.7.x, but it works in non-debug mode for me.

When I need to update skin folders on our production server then I do that 
by forcing the skin product to refresh. For other products I restart the 
servers, but as Reinoud points out if you have multiple ZEO clients that 
doesn't result in any downtime (we currently have 6 ZEO clients) although 
it will result in a slower response for the first few hits after the 
restart.

___
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: No joy on 8080.

2006-06-26 Thread Duncan Booth
Ignacio Valdes wrote:

> This is all on a headless server by ssh so I can't check 
> http://localhost:8080 but http://server ip address:8080 on my browser 
> doesn't work. 

Maybe there is a firewall blocking your access to port 8080 on the
server. Try using wget running on the server to fetch the page locally 
"wget http://localhost:8080"; should work, or set up an ssh tunnel. On your 
local machine login to the server using the command:

   ssh -L 9080:localhost:8080 yourserver

which will forward port 9080 on your local machine to localhost:8080 on 
your server. Then you should be able to access the Zope instance as 
localhost:9080 in your browser.

___
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: kupu drawers

2006-03-28 Thread Duncan Booth
Garito wrote:

> this.shared.xmldata.setProperty is not a function
> 
> I supouse that the error is raised because the xml is incorrect but I 
> can't see where
> 

I think this could happen if you gave the wrong content-type for your XML. 
If the browser doesn't realise that it is supposed to be XML then it won't 
bother parsing it. Kupu trunk has code to check for this and build a DOM if 
the browser hasn't bothered, but earlier releases (such as 1.3.x) don't.

___
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: Presentations Available

2005-10-04 Thread Duncan Booth
David H wrote:

> I saw that in a few google hits but ... I figured that if a fair 
> population wants to view the presentations then the files should be in a 
> universal format - like pdf or rtf. 
> Its an interesting question:  how many people who just wish to peruse 
> the files will feel compelled to google and download new apps just to be 
> able to read them?
> 
Why download anything? You can do the conversion online at
http://cdsconv.cern.ch/index.py/Simple?s_id=sxi

I agree with you in general though that uploading them as pdf would have 
been a good idea especially since, unlike certain other office 
applications, the conversion is a built-in feature of OpenOffice.

___
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: Epoz and Tidy

2005-05-05 Thread Duncan Booth
Cyrille Bonnet wrote:

> Daniel Dekany wrote:
>> BTW, anybody has found a solution for fixing HTML copy-pasted from
>> Microsoft Word (mostly 2000/XP)? Lot of users has MS Word, and the
>> HTML pasted from it is a CSS killer mess. I tried mxTidy but it
>> didn't improved substantially the HTML. So how do you guys do it? I
>> have looked after solutions for Epoz, but didn't found any. But I
>> don't stick to Epoz... if there is a solution already for Kupu (is
>> Kupu already recommended over Epoz anyway?). Certainly the solution
>> would be an Epoz post-tidy Python script, but I didn't found any for
>> Word tidying. (However, the ideal would be if the HTML is tidied
>> right on the client when it pastes it in -- thus user would really
>> get what it sees, i.e. the HTML wouldn't be changed when he saves it.
>> That effect is really evil.)
>> 
>> 
> As Shane pointed out, there is a tidy up in Kupu. However, in my 
> experience, it is not a very good tidy up (if I remember correctly, a 
> lot of tags are still there after the tidy up).
> 
Unfortunately there is a fine line between tidying up the cruft pasted from 
Word, and not stripping out things which might actually have been entered 
legitimately. I think Kupu does this pretty well (but then I'm a bit 
biased), but without any way to detect that the user is pasting from Word I 
don't see how much more could be stripped.

So far as I know the only thing which doesn't really get stripped from the 
pasted Word text are the mso classnames. These can be manually blacklisted, 
but I never got round to producing a definitive blacklist.

One of my thoughts is to provide a separate 'clean this up' button which 
would apply a more aggressive tidy-up than the one when saving. Also, I 
agree that only applying the tidy on save is bad, but there isn't a cross-
browser way to detect a paste, and applying the cleanup on a large 
document every time you cut/paste one word wouldn't be nice either.

Suggestions for improvements are most welcome.

P.S. It isn't just pasting bad HTML which is a problem: some Microsoft 
applications supply RTF on the clipboard but not HTML and it turns out that 
if you paste RTF into IE it generates seriously invalid HTML with a totally 
weird and corrupted DOM. That is another area where I think the cleanup 
code finally does a passable job but not yet a perfect one.

___
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: ZPT and attributes

2005-04-09 Thread Duncan Booth
Antonio Beamud Montero wrote:

> How I can create attribute names dynamically?
> For example, I want something like this:
>http://boo"; ref2="http://foo"; ...>
> 
> Where ref1 and ref2, are created by the url list.
> I have done in DTML because I cannot with ZPT.
> 

The easiest way is probably to create the tag in something else (e.g. a 
Python script) and then just insert it into your output at the relevant 
point:



A better solution would be to avoid doing this in the first place.

___
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] Underscore Caracter

2000-09-06 Thread Duncan Booth

Tino Wildenhain wrote:

> > Turn "asd_asd" into "asd asd" and output:
> > 
> > 
> > 
> I've seen this on plenty lines of digicools code and wondered
> about if this is more efficient then using just string.replace()
> ?
> I would say string.replace() should be a bit faster.

I think the reasons may be historical. For a long time the Zope 
documentation listed the join and split members of the string 
module, but whoever wrote the documentation the first time around 
missed out replace. So anyone coming at Zope from the DTML 
direction is likely not to spot the replace method.

Calling _.string.replace requires two attribute lookups and one 
python method call. replace itself requires zero or one memory 
allocation for the result.
Calling join/split requires four attribute lookups, two python method 
calls and n+3 memory allocations where n replacements are made 
(1 allocation when n is 0).

So I agree, replace should be faster, although given everything else 
that is going on, unless you do a lot of them you probably won't 
notice.

-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




[Zope] Anyone using Zope on a RAQ3?

2000-08-02 Thread Duncan Booth

Has anyone tried running Zope on a Cobalt RaQ3?
The reason I ask is that a UK company is now offering dedicated 
RaQ3's for 29 pounds/month (64Mb RAM, 8Gb disc), and I 
wondered if it would make a good Zope platform or not?

-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] dtml-in question

2000-08-02 Thread Duncan Booth

> I had the same problem and found out there is no way yet of making dtml-in
> with multiple conditions. Instead I had to do dtml-if's and make my own
> counter and previous/next attributes to handle the batches.
> 
One way to simplify this is to use two dtml-in loops. The first one 
filters out the items you want to include, then the second one just 
displays all the items in the filtered loop.

So instead of:
   
  messing around with counters and stuff goes here...
   

You have something like:
   
   
   

Put your real loop body here. 
   

The second sequence then has the correct counter, and you can 
use the next/prev batches on it as well if you want.

When building the second sequence you have a choice of how to 
structure it. If you simple append sequence-item, this should work, 
unless the sequence items are two element tuples. If you append a 
tuple as shown this should work every time. It can also be useful to 
calculate a new key, for example if you wanted to sort the list on 
more than one field you could build a key from the sorted fields.

The main downside to this scheme is that you have to process the 
whole list, which could be annoying if you just want a small batch 
from the front of a long list.

-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




RE: [Zope] URL quoting in python

2000-07-21 Thread Duncan Booth



> I often create an external method for this...
> 
> em:
> 
> def url_quote(s):
>import urllib
>return urllib.quote_plus(s, safe='')
> 
> Silly, but it works.
> 
> I think the alternative is to hack the DT_Util.py module in the
> DocumentTemplate directory to expose urllib or a derived function.

Isn't an external method a bit overkill? It is possible to just create a 
DTML Method called url_quote where the body is:


(making sure there is no whitespace before this line, and no 
newline after it.)

Then from any other DTML method you just call it remembering to 
pass in the parameter by name.

e.g. 
 

Re: [Zope] How to require an @ symbol in email form field??

2000-07-18 Thread Duncan Booth

> Is there a way to require at least an "@" sign in the email field? The
> powers that be think this would be useful.
... complain here ...

> 
> Here's the form processing code as it stands today. Any help is
> appreciated.
Use javascript to check that all required fields are present before 
the form is actually submitted. Here is some of the code I use:





where jsvalidate is a DTMLDocument that may be found at 
http://www.zope.com/members/Duncan/jsvalidate.

Also, consider using the :default modifier on fields to force them to 
have a value. For example, if you put


then if the field is left empty, or in the case of a radio button not 
selected, the default value will be used.

> 
... code snipped ...

Here's a somewhat shorter, albeit more obscure, way to check 
whether all the fields you want are in the REQUEST form:



Missing fields:
  

  ... insert code here ...




-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] Zope, Apache/NT, Reliability issues

2000-06-09 Thread Duncan Booth

> > My test platform is a Windows NT 4 running Apache 1.3.12. The first
> > doubt comes to the fact that I could not find the pcgi module for NT (I
> > do not have any kind of C compiler, so I´ll be very glad if anyone know
> > a binare version). So I´d like to know where can I find informations
> > about installing Zope using PCGI in an NT Apache installation.
> 
> It could be someone else has already compiled it and used it.

I see that the latest version of the fastcgi module now claims to 
have beta Win32 support so this may make a suitable alternative to 
PCGI. Has anyone out there tried FastCGI on NT?


-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] stupid question I guess

2000-06-08 Thread Duncan Booth

> but I can't find the answer...
> 
> can I set a local variable in zope on a dtml page
> eg
> 
> 

I had a few thoughts on creating writeable local variables so I put 
them down in a HowTo. See
http://www.zope.org/Members/Duncan/LocalVars
for instructions on a different way to manipulate local variables in 
Zope. Basically, by addinga small python method, it lets you write 
code like:
 
  
  
 
  
  

and get:
   1 a string 3 a str 
as output.

-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] Problems with pcgi_wrapper.exe

2000-06-01 Thread Duncan Booth

> I am running Zope as a service under WinNT workstation. I am running it
> behind "Personal Web Server". Problem is that pcgi_wrapper.exe seems to
> hang. If I access a page with a large graphic on it I might get the page but
> the graphic will not come but it will still try loading it. Anyone had a
> similar problem?
> 

There seem to be a variety of reasons for pgi_wrapper to hang on 
NT. In my case, running behind Netscape it hangs when someone 
requests an objects and then closes the connection before the 
object is sent back from pcgi_wrapper to the Netscape server. In 
this situation it appears that Netscape fails to close the pipe, but 
never reads from it.

I think there may also be a situation where the NT version can hang 
if Zope throws an exception within its handling of the pcgi request 
(pcgiReadSocket checks its result only for SOCKET_ERROR 
whereas pcgiRead checks for any error or for a 0 return). When 
Zope throws an exception it can close its socket without writing the 
data and the recv call then repeatedly returns 0. You should be 
able to tell if this is the problem because the hung pcgi_wrapper 
will be consuming all available CPU. If it hangs because the output 
pipe is closed it consumes no CPU.

What I can offer anyone who is having problems with pcgi_wrapper 
on NT is a specially patched version that shoots itself after it has 
been running for 1 hour (or any other delay if you recompile it). As 
a bonus, when it does shoot itself it writes the the pcgi logfile a 
message telling you on which line it hung. Unfortunately 
(confession time) I don't seem to have saved a copy of the source 
for the version that prints out the line number, just the binary. I do 
have source though for the version that shoots itself, but doesn't tell 
you how far it got. I have uploaded the relevant files to
http://www.zope.org/Members/Duncan/pcgimods


-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] how do I get field names from a query

2000-05-31 Thread Duncan Booth



> how do I get the names of the fields returned from a SQL query ?
> ( I would like to generate stuff using the names automatically)
> I know they must be available because I can use them directly !
The result of the SQL query has a method 'names()' that contains 
the column names.  N.B. This is a method of the result, not a 
method of the individual rows, so you cannot normally get at it 
directly while iterating over the result.

> 
> I've tried lots of alternatives of the form
> 
> 
>
>   
> 

Try:

 
  
  
    
    is 

  
  


-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] Use of lambda expression in DTML

2000-05-30 Thread Duncan Booth

> In brief: I get a NameError when invoking "filter(...)" from DTML.  I thought this 
>was a built-in python method, so I'm a bit puzzled.

Python's ideas of 'built-in' is simply any method in the module 
stored in the global variable called __builtins__. Any code executed 
with a non-standard global variable space may or may not have the 
same set of builtins as normal Python code.

Unfortunately Zope does not expose all of the 'builtin' python 
methods to DMTL expressions. Some obviously need to be cut out 
(such as 'open') for security reasons, but the reasons why others 
were dropped are less obvious.

If you really need any of the missing builtins back in you have a 
couple of choices. Both require you have full access to your Zope 
system.

If you want the function available throughout your Zope system 
simply edit DocumentTemplate\DT_Util.py. Look for the list 
beginning 'None', 'abs', 'chr' and simply add 'filter' into the list.

Alternatively if you dont want to patch Zope directly, create an 
external python method that exposes filter.

> 5) In the dtml-tree tag, I change it to:
> 
>  Technical 
>   leaves=dtcTemplate 
>   branches_expr="filter( lambda f: not 
>f.hasProperty('blockTreeBranching', false), objectValues(['Folder']) )">
> 
> which, all things equal, should DoTheRightThang.

Even if you make the filter function visible as described above, this 
still won't quite work. For example the method 'objectValues' is not 
in scope within the function. The way around this is to pass in an 
extra parameter _vars. Try (untested):

branches_expr="filter( lambda f, _vars=_vars: not 
f.hasProperty('blockTreeBranching', 0), objectValues(['Folder']) )">  

and it might work.

Alternatively use something like a PythonMethod, or even a DTML 
method and simply write the filter loop out in full using 'for' or 'dtml-
in'.

-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] calling an Python builtin function

2000-05-25 Thread Duncan Booth

> Beside of this, is there a way to test if foo is a string or a
> sequence or whatever ??
apart from changing your form to force the list type, you could try 
(untested code):


...


There is no easy way to check whether a value in Zope is a list, 
tuple, or integer, but there is an easy way to check whether it is a 
string since strings are the only type left unchanged by the str 
function.

More advanced type recognition generally requires trying various 
things and catching the exceptions that are raised. I have put a 
PythonMethod that does general type recognition in a HowTo at 
http://www.zope.org/Members/Duncan/RecogniseTypes


-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] Zope log rotation

2000-05-22 Thread Duncan Booth

> Dear All:
> 
> Quick question about Zope admin.
> Can zope automatically rotate its access log? Thanks.

Edit z2.py. Change the line:

lg = logger.file_logger(LOG_PATH)

to:

lg = logger.rotating_file_logger(LOG_PATH, freq='daily', 
maxsize=400)

You can use 'daily', 'weekly' or 'monthly' for the frequency of 
rotation.

-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )




Re: [Zope] Has anyone...?

2000-05-18 Thread Duncan Booth



> ...run multiple instances of Zope on an NT machine?
> I guess I should ask first if anyone has been successful getting thier NT
> Web Server to handle authentication/authorization to zope users via pcgi?
Yes and no. One of our servers is currently quite happily running 
two copies of Zope behind Apache. Several different virtual hosts 
are then redirected to one or other of the Zope servers. We aren't 
using PCGI though, instead we are using the PROXYPASS feature 
in Apache coupled with SiteAccess in Zope.


-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
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 )