[Zope-Checkins] SVN: Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py This is just me being picky about whitespace. Nothing to see here, move along.

2006-04-08 Thread Stefan H. Holek
Log message for revision 66686:
  This is just me being picky about whitespace. Nothing to see here, move along.
  

Changed:
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py

-=-
Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py
===
--- Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py 2006-04-08 16:28:43 UTC 
(rev 66685)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py 2006-04-08 17:01:22 UTC 
(rev 66686)
@@ -132,9 +132,9 @@
 environ['SERVER_NAME'] = _Z2HOST or 'nohost'
 environ['SERVER_PORT'] = '%d' % (_Z2PORT or 80)
 environ['REQUEST_METHOD'] = 'GET'
-app = _makerequest(app, stdout=stdout, environ=environ)
-return app
+return _makerequest(app, stdout=stdout, environ=environ)
 
+
 def appcall(function, *args, **kw):
 '''Calls a function passing 'app' as first argument.'''
 from base import app, close

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


Re: [Zope] TextIndexNG and ExtFile

2006-04-08 Thread Stefan H. Holek
This is fixed on SVN trunk [1]. I hope to get around to releasing  
1.5.0 sometime soon-ish. Please also note that it is *not safe* to  
use 1.4.4 with Zopes  2.7 because of major changes in the  
transaction machinery of Zope.


Stefan

[1] svn co https://svn.plone.org/svn/collective/ExtFile/trunk ExtFile


On 7. Apr 2006, at 23:22, Michael Vartanyan wrote:




I've got a site with a couple hundred ExtFile objects. I now need  
to index the content of the various files (word, pdf, excel, ppt).  
I see that ExtFile doesn't have a PrincipiaSearchSource method so  
I created one. It returns self.index_html(). When I go back into  
my catalog and reindex my PrincipiaSearchSource index (a  
textindexng index), clicking the Reindex button opens the  
ExtFile I'm trying to index. Is there something more to the  
process of trying to index ExtFiles with TextIndexNG. I've googled  
around and tried a few things but either they don't work or I get  
the same results I've just described. Any ideas?




this is what was discussed here:

http://mail.zope.org/pipermail/zope/2006-March/165803.html
http://mail.zope.org/pipermail/zope/2006-April/165924.html


and a number of times before. Looks like someone needs to really  
look at this. I will try to do that over the weekend, if nothing  
works... well, my 19k ExtFiles will have to turn into Chris' blobs :-)

___


--
Anything that happens, happens.  --Douglas Adams
___
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] filtering results

2006-04-08 Thread gf
On 4/7/06, Dieter Maurer [EMAIL PROTECTED] wrote:
 gf wrote at 2006-4-6 12:06 -0600:
 Hi,
 I am a Zope newbie. I apologize if the terminology I use below is not
 correct, but I hope that you get the gist of what I am about to ask.
 
 I would like to be able to 'filter' results before returning them to
 the user.  In other words, if a user requests a given object, it is
 passed through a filter before being passed on to him or her. As a
 simple example, I may want to tidy the html before the user sees it,
 or eliminate or add certain tags or words.
 
 I have put together a simple 'html tidy' external method that takes
 raw html and produces a tidied version, but I don't know how I can
 apply it.

 The current Zope version does not support general post processing.


 Depending on your precise use cases, you have various options:

  *  change ZPublisher.HTTPResponse.HTTPResponse to
 perform postprocessing it its setBody.

  *  change ZPublisher.Publish.publish_module to add
 post processing

  *  use a PythonScript and its traverse_subpath feature.

 When traversal reaches a PythonScript, then traversal
 stops and the remaining traversal steps are
 made available in the scripts traverse_subpath.

 The script can try to locate the object identified
 by the traverse_subpath and call it.
 It then can perform post processing on the result.

 This usually works for templates and parameterless scripts.
 Passing parameters to scripts is difficult.
 You probably would like to make ZPublisher.mapply.mapply
 available in untrusted code for this.

 The approach will also fail when the user can only be authenticated
 below the script.
 --
 Dieter


Hi Dieter,
Thank you for the ideas!
I will check into them and see if I can make anything work for my application.

Best Regards,
gyro
___
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] Problems Executing pdftk from within zope.

2006-04-08 Thread Jerry Westrick
On Saturday 08 April 2006 01.24, Jonathan wrote:
 Have you tried running it as a spawned job from the shell?  If something is
 pooched in the environment then the job should hang (then you know it is
 not a zope problem).

 Jonathan


Using the if __name__ == '__main__': main()
I have executed the command from the External script file
(as user root) with python aw4.py ecmd2 and it works...

But when called from zope it hangs...

I've tried with popen(...)
and spawnv(...)

I've had the script dump the environment variables
and the version dumped by root, differs from the version 
dumped from zope only in variables with cookie in them!

Now I tried to do a simple cat  and it don't seam to work either...

I'm quite fustrated so it's time to go have fun (install SUSE 10 XEN on SUSE 
10   Whp!).

If anyone, anywhere has any ideas WTF is going on here,
please give me a hint!


Jerry




___
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] TextIndexNG and ExtFile

2006-04-08 Thread Michael Vartanyan

Many thanks Stefan, that worked for me!


Stefan H. Holek wrote:
This is fixed on SVN trunk [1]. I hope to get around to releasing 
1.5.0 sometime soon-ish. Please also note that it is *not safe* to use 
1.4.4 with Zopes  2.7 because of major changes in the transaction 
machinery of Zope.


Stefan

[1] svn co https://svn.plone.org/svn/collective/ExtFile/trunk ExtFile


On 7. Apr 2006, at 23:22, Michael Vartanyan wrote:




I've got a site with a couple hundred ExtFile objects. I now need to 
index the content of the various files (word, pdf, excel, ppt). I 
see that ExtFile doesn't have a PrincipiaSearchSource method so I 
created one. It returns self.index_html(). When I go back into my 
catalog and reindex my PrincipiaSearchSource index (a textindexng 
index), clicking the Reindex button opens the ExtFile I'm trying 
to index. Is there something more to the process of trying to index 
ExtFiles with TextIndexNG. I've googled around and tried a few 
things but either they don't work or I get the same results I've 
just described. Any ideas?




this is what was discussed here:

http://mail.zope.org/pipermail/zope/2006-March/165803.html
http://mail.zope.org/pipermail/zope/2006-April/165924.html


and a number of times before. Looks like someone needs to really look 
at this. I will try to do that over the weekend, if nothing works... 
well, my 19k ExtFiles will have to turn into Chris' blobs :-)

___


--
Anything that happens, happens.  --Douglas Adams
___
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] filtering results

2006-04-08 Thread Cliff Ford
This is my implementation of an external method that calls HTML Tidy. I 
hope it is of some use.


This is a fragment of a form processing script that calls an External 
Method, passing the body content of a html page:


if request.submit == 'Tidy':
(messages, buffer) = context.calltidy(body)
request.set('messages', messages)
request.set('body', buffer)
return

The body and any HTML Tidy messages are passed back to the form for 
display. The external method module name is caltidy and the function 
name is tidy.


This is the external method that calls HTML Tidy. It prepends a suitable 
head and appends a suitable tail to the body (shich happens to be part 
of a table) to make a valid html document, then chops them off the 
result for return to the caller:


# call htmltidy
import os
import string

# path to executable
#exe = '/usr/local/zopeinst/Extensions/htmltidy/tidy'
exe = '/disk/home/www/zopeinst/Extensions/htmltidy/tidy'

# path to HTML Tidy configuration file
#config = '/usr/local/zopeinst/Extensions/htmltidy/config.txt'
config = '/disk/home/www/zopeinst/Extensions/htmltidy/config.txt'
errors = ''
#

dummyhead = 
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN 
http://www.w3.org/TR/html4/loose.dtd;

html lang=en
head
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
titleTesting/title
/head
body
table summary=dummy tabletrtd
!-- dummyhead --

dummytail = 
!-- dummytail --
/td/tr/table
/body
/html
.

parsefailed = 
Tidy has not changed the source. This will happen if the input
contains any tags not recognised by the html specification. Do
not use Tidy on pages containing dtml! Correct only the errors
listed below and then run Tidy again. Tidy will convert font tags
to style classes, which will be ignored unless you create a local
style sheet. Tidy will also correct many other faults that lead
to the warnings below. The first line of your text is line 11.



def tidy(input):
combo = dummyhead + input + dummytail
command = %s -config %s 21  .\n%s % (exe, config, combo)
buffer = ''
# get results from tidy into buffer
for line in os.popen(command).readlines():
buffer += line
# if anything goes wrong with the tidy call the line count is zero
try:
# chop the dummy head
(head, buffer) = string.split(buffer, '!-- dummyhead --')
# keep the warnings part of the head
(head, tail) = string.split(head, '!DOCTYPE')
# and chop the dummy tail
(buffer, tail) = string.split(buffer, '!-- dummytail --')
return (head, buffer)
except:
return (parsefailed + buffer, input)

Cliff

gf wrote:

Hi,
I am a Zope newbie. I apologize if the terminology I use below is not
correct, but I hope that you get the gist of what I am about to ask.

I would like to be able to 'filter' results before returning them to
the user.  In other words, if a user requests a given object, it is
passed through a filter before being passed on to him or her. As a
simple example, I may want to tidy the html before the user sees it,
or eliminate or add certain tags or words.

I have put together a simple 'html tidy' external method that takes
raw html and produces a tidied version, but I don't know how I can
apply it.

Thank you for any comments, suggestions, or simple examples you may be
able to provide.

Best  Regards,
gyro
___
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] Problems Executing pdftk from within zope.

2006-04-08 Thread Jonathan
Don't know if this will help, but here is a line from one of my external 
methods that works:


   rstat = commands.getstatusoutput('./qrcode '+quoted_instr)

'qrcode' is a bash script file (linux) that resides in '/apps/zope/var' (no 
messing around with PATH or environment variables) and takes a string 
'quoted_instr' as an input parameter.


if you do 'return str(rstat)'  after the call you should get some error info 
if the call fails.


HTH

Jonathan


- Original Message - 
From: Jerry Westrick [EMAIL PROTECTED]

To: zope@zope.org
Sent: Saturday, April 08, 2006 10:47 AM
Subject: Re: [Zope] Problems Executing pdftk from within zope.



On Saturday 08 April 2006 01.24, Jonathan wrote:
Have you tried running it as a spawned job from the shell?  If something 
is

pooched in the environment then the job should hang (then you know it is
not a zope problem).

Jonathan



Using the if __name__ == '__main__': main()
I have executed the command from the External script file
(as user root) with python aw4.py ecmd2 and it works...

But when called from zope it hangs...

I've tried with popen(...)
and spawnv(...)

I've had the script dump the environment variables
and the version dumped by root, differs from the version
dumped from zope only in variables with cookie in them!

Now I tried to do a simple cat  and it don't seam to work either...

I'm quite fustrated so it's time to go have fun (install SUSE 10 XEN on 
SUSE

10   Whp!).

If anyone, anywhere has any ideas WTF is going on here,
please give me a hint!


Jerry




___
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] Problems Executing pdftk from within zope.

2006-04-08 Thread Dieter Maurer
Jerry Westrick wrote at 2006-4-8 00:42 +0200:
I trying to modify pdf files from within zope.
I use the following command:

'/usr/bin/pdftk /t/in.pdf attach_files /t/a1.pdf /t/a2.pdf output /t/out.pdf'

When I execute it as root it works...

I do not know what pdftk does.
But from your description, it would be really strange when it required
execution as root. If it really does, I would say: do not use it!

When executed from within zope, 
(this i've done via external command that executes os.system(...))
A task is started to executed it, but the task hangs.

Apart from the most recent Python versions, earlier Python versions
had a bug: forked processes from multi-threaded applications (such
as Zope) had all signals blocked. Thus, when a forked application
used signals (e.g. alarm), it could hang.
Checking the sigmask of the application can tell you whether
this problem still exists with your Python version.


The most recent Python versions in the 2.3 and 2.4 series should have
this problem fixed.


-- 
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] Problems Executing pdftk from within zope.

2006-04-08 Thread Jerry Westrick
On Saturday 08 April 2006 20.47, Dieter Maurer wrote:
 Jerry Westrick wrote at 2006-4-8 00:42 +0200:
 I trying to modify pdf files from within zope.
 I use the following command:
 
 '/usr/bin/pdftk /t/in.pdf attach_files /t/a1.pdf /t/a2.pdf output
  /t/out.pdf'
 
 When I execute it as root it works...

 I do not know what pdftk does.
 But from your description, it would be really strange when it required
 execution as root. If it really does, I would say: do not use it!

 When executed from within zope,
 (this i've done via external command that executes os.system(...))
 A task is started to executed it, but the task hangs.

 Apart from the most recent Python versions, earlier Python versions
 had a bug: forked processes from multi-threaded applications (such
 as Zope) had all signals blocked. Thus, when a forked application
 used signals (e.g. alarm), it could hang.
 Checking the sigmask of the application can tell you whether
 this problem still exists with your Python version.

Ahhh, I bet this is the problem...


 The most recent Python versions in the 2.3 and 2.4 series should have
 this problem fixed.
___
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] Problems Executing pdftk from within zope.

2006-04-08 Thread Jerry Westrick
On Saturday 08 April 2006 20.47, Dieter Maurer wrote:
 Jerry Westrick wrote at 2006-4-8 00:42 +0200:
 I trying to modify pdf files from within zope.
 I use the following command:
 
 '/usr/bin/pdftk /t/in.pdf attach_files /t/a1.pdf /t/a2.pdf output
  /t/out.pdf'
 
 When I execute it as root it works...

 I do not know what pdftk does.
 But from your description, it would be really strange when it required
 execution as root. If it really does, I would say: do not use it!

 When executed from within zope,
 (this i've done via external command that executes os.system(...))
 A task is started to executed it, but the task hangs.

 Apart from the most recent Python versions, earlier Python versions
 had a bug: forked processes from multi-threaded applications (such
 as Zope) had all signals blocked. Thus, when a forked application
 used signals (e.g. alarm), it could hang.
 Checking the sigmask of the application can tell you whether
 this problem still exists with your Python version.


I bet this is the problem...
What should the Sigmask look like?

Later on tonight, I'll publish what the values are,
and what versions of python I'm using...



 The most recent Python versions in the 2.3 and 2.4 series should have
 this problem fixed.


Hmm I'll look into this also, although Zope requires specefic versions...


Thx...
Jerry

P.S. Sorry about the preveous post

___
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] how to include a local html file

2006-04-08 Thread Chris Purves
On Saturday 08 April 2006 08:57, Chris Purves wrote:

 How can I include an html file on my local filesystem into a DTML method?

At the suggestion of David H, I installed the localfs product which allowed me 
to access local files.  I then used a page template instead of a DTML method 
and was able to insert the file.

-- 
Good day, eh.
Chris
___
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 )