[Zope] Allow import of whole filesystem class hierarchy?

2007-01-24 Thread Kirk Strauser
My company has a Zope server that has no editing rights for external 
persons - only employees have management permissions.  We also have a 
company-specific hierarchy of several hundred Python modules that I'd like 
to access from Zope.  Rather than modifying each and every module as per 
the instructions in the Security chapter of the ZDG, is there a way to 
say allow the import of any module inside this part of $PYTHONPATH?

Oh, for those curious: part of the reason for moving code from Zope Python 
scripts and into filesystem code is that my company has officially adopted 
Python as our new development platform for new projects.  I'm cranking out 
thousands of lines of code, and the Windows guys are tweaking it to run 
under IronPython.  The end goal is to have a library of code that runs 
under Unix, Windows, Mac, or wherever else we might want to explore, and 
then to write frontends to that library in whatever seems appropriate to 
the task.  For example, new web apps will be written with Zope calling 
those modules.  New GUI apps will be written with Visual Studio calling 
those modules.  Yay Zope and Python!  You're what broke us away from vendor 
lock-in!
-- 
Kirk Strauser
Daycos
___
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: Allow import of whole filesystem class hierarchy?

2007-01-24 Thread Kirk Strauser
On Wednesday 24 January 2007 10:30 am, Tres Seaver wrote:

 The most straighforward hack to do what you want would be to
 monkey-patch 'AccessControl.ZopeGuards.guarded_import', which is the
 function that does the current checking.

Before I start on such an adventure, what is the Python/Zope term for what 
I'm trying to do, specifically to allow the import of an entire module, 
including classes inside it, and methods inside those classes' objects?

 However, your *best* bet is to implement your Zope applications as
 filesystem-based products, rather than in untrusted code (Python
 scripts).  At that point, the modules are easily importable.

Maybe so, but I'm not looking forward to re-writing several years worth of 
production code.  I was really hoping for a simple switch that told Zope to 
blanketly let me use a module and its contents.  I'm still somewhat in 
disbelief that it's not there.
-- 
Kirk Strauser
Daycos
___
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] Has anyone generated barcodes output within DTML?

2006-12-04 Thread Kirk Strauser
On Monday 04 December 2006 9:30 am, [EMAIL PROTECTED] wrote:

 It is a simple question, has anyone generated barcodes output within
 DTML?

Sure!  I cheated by making a GIF of every barcode digit, then in my page, I 
just print the image tags in order.  Ain't fancy but it's been working 
perfectly for several years.

I factored the actual code into a Python script that also knows how to 
generate checksum digits if desired, but you might not need that.
-- 
Kirk Strauser
Daycos
___
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] Wrong time displayed on events

2006-12-03 Thread Kirk Strauser
I've just installed Plone 2.5.1 on Zope 2.9.6 running on FreeBSD 6-STABLE.
On my newly created Plone site, whenever I add an event, it's displayed
with the wrong time.  For instanced, if I create one that runs between
2006-12-05 19:30 and 22:00, it gets rendered like:

    (span class=locationSome Event/span, from
         abbr class=dtstart title=2006-12-05 19:30:002006-12-05 
13:30/abbr to
         abbr class=dtend title=2006-12-05 22:00:002006-12-05 
16:00/abbr)

The server and I live in the CST time zone, which accounts for the 6-hour
offset (as though I entered the time in UTC and it's converting it to CST
for display).  But since I never entered a timezone anywhere, why's it
doing any conversion at all instead of just assuming that all times entered
are local to the server?  Is there a way to fix this, other than
deliberately entering all times for events six hours too late, and
letting Plone fix the display?
-- 
Kirk Strauser
Daycos
___
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] Can't stop Zope, machine hanging

2006-09-05 Thread Kirk Strauser
On Tuesday 05 September 2006 3:58 am, Chris Withers wrote:

 Move hosters. FreeBSD for all its robustness is not something I'd
 recommend running Zope on...

Seriously?  Why so?  I've been running Zope exclusively on FreeBSD since 
2001 without any known problems.
-- 
Kirk Strauser
The Day Companies
___
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 )


SOLVED! (was Re: [Zope] Content-Disposition is driving me batty)

2006-08-18 Thread Kirk Strauser
On Thursday 17 August 2006 10:55 am, David H wrote:

 I had similar problems too.  This seems to work with IE:
  theFile=open( self.pdfpath,'rb')
  result = theFile.read()
  
  RESPONSE.setHeader('Content-Type','application/pdf')
  RESPONSE.setHeader(Content-Disposition,filename=report.pdf)
  RESPONSE.setHeader('Content-Length',len(result))
  RESPONSE.write(result)

Sending the Content-Length header fixed the problem.  PDFs now appear 
inline and with their expected contents.  I haven't diffed the code between 
2.8 and 2.9, but I'm guessing that Zope used to send that header by default 
but no longer does.
-- 
Kirk Strauser
The Day Companies
___
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] Some users can't view sent PDFs anymore

2006-08-17 Thread Kirk Strauser
Since upgrading from Zope 2.8.something to 2.9.3, many of our customers
can no longer view PDFs that we send them.  If they're using Internet
Explorer, they often get a blank page when trying to view them (and we
haven't been able to nail down the exact combination of Windows + IE +
Acrobat that causes the problem).

Here's the Python script we use to send the files:

## Script (Python) download
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=filename,password=None,skipctypeheader=None
##title=
##
request = container.REQUEST
RESPONSE =  request.RESPONSE

stockexception = 'FileUnavailableError'

# Does the file exist?
if not filename in context.files.objectIds():
raise stockexception

file = context.files[filename]

# Does the given password match the one on the file?
if file.getProperty('password', d=None) != password:
raise stockexception

if not skipctypeheader:
# Set the content type if one is defined for the file
ctype = file.getProperty('content_type', d=None)
if ctype:
RESPONSE.setHeader('Content-Type', ctype)

RESPONSE.setHeader('Content-Disposition', 'inline; filename=%s' % filename)

return context.files[filename]

Here's the output of running 'curl' to fetch one:

$ curl -vv 
'http://web2.xrsnet.com/publicstore/download?filename=print.pdfpassword=foo'  
/dev/null
* About to connect() to web2.xrsnet.com port 80
*   Trying 10.45.14.64... connected
* Connected to web2.xrsnet.com (10.45.14.64) port 80
 GET /publicstore/download?filename=print.pdfpassword=foo HTTP/1.1
 User-Agent: curl/7.15.1 (i486-pc-linux-gnu) libcurl/7.15.1 OpenSSL/0.9.8a 
zlib/1.2.3 libidn/0.5.18
 Host: web2.xrsnet.com
 Accept: */*

 HTTP/1.1 200 OK
 Date: Thu, 17 Aug 2006 14:34:12 GMT
 Server: Zope/(Zope 2.9.3-, python 2.4.3, freebsd6) ZServer/1.1
 Content-Length: 1742
 Content-Type: application/pdf; charset=iso-8859-15
 Content-Disposition: inline; filename=print.pdf
 Vary: User-Agent
  % Total% Received % Xferd  Average Speed   TimeTime Time  
Current
 Dload  Upload   Total   SpentLeft  
Speed
100  1742  100  17420 0  20835  0 --:--:-- --:--:-- --:--:--  
541k* Connection #0 to host web2.xrsnet.com left intact

* Closing connection #0

I feel kind of sheepish about blaming Zope, but everything worked perfectly
one day, I did the upgrade that night, and the complaints started rolling
in the next morning.

If nothing else, would some IE users be kind enough to try to view this
tiny PDF and see whether it opens inline or externally, and whether it
displays actual content (the phrase This is a test.) or a blank page:

http://web2.xrsnet.com/publicstore/download?filename=print.pdfpassword=foo

Many thanks in advance.  My boss is increasingly unamused and I'm out of
ideas.
-- 
Kirk Strauser
The Day Companies
___
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] Content-Disposition is driving me batty

2006-08-17 Thread Kirk Strauser
I have a Python script that transmits a file to the user.  An excerpt:

if not skipctypeheader:
# Set the content type if one is defined for the file
ctype = file.getProperty('content_type', d=None)
if ctype:
RESPONSE.setHeader('Content-Type', ctype)

RESPONSE.setHeader('Content-Disposition', 'inline; filename=%s' % filename)

We most commonly use this to send PDF reports.  After a recent upgrade
from Zope 2.8.something to 2.9.3 (on FreeBSD via ports), IE users can
only sometimes get the file - they otherwise get a blank page. 

Running 'curl' gives the header values I'd expect:

$ curl -vv -O 
'http://web2.xrsnet.com/publicstore/download?filename=print.pdfpassword=foo'  
/dev/null
* About to connect() to web2.xrsnet.com port 80
*   Trying 10.45.14.64... connected
* Connected to web2.xrsnet.com (10.45.14.64) port 80
 GET /publicstore/download?filename=print.pdfpassword=foo HTTP/1.1
 User-Agent: curl/7.15.1 (i486-pc-linux-gnu) libcurl/7.15.1 OpenSSL/0.9.8a 
 zlib/1.2.3 libidn/0.5.18
 Host: web2.xrsnet.com
 Accept: */*

 HTTP/1.1 200 OK
 Date: Wed, 16 Aug 2006 22:26:11 GMT
 Server: Zope/(Zope 2.9.3-, python 2.4.3, freebsd6) ZServer/1.1
 Content-Length: 1742
 Content-Type: application/pdf; charset=iso-8859-15
 Content-Disposition: inline; filename=print.pdf
 Vary: User-Agent
  % Total% Received % Xferd  Average Speed   TimeTime Time  Current
 Dload  Upload   Total   SpentLeft  Speed
100  1742  100  17420 0  30301  0 --:--:-- --:--:-- --:--:-- 0* 
Connection #0 to host web2.xrsnet.com left intact

* Closing connection #0


Would some IE users please let me know whether they can view this PDF
normally?

http://web2.xrsnet.com/publicstore/download?filename=print.pdfpassword=foo

Any speculation about what might be causing this is extremely welcome.  I'm
*not* looking forward to rolling back to 2.8.x (and Python 2.3) at this
point.
-- 
Kirk Strauser
The Day Companies

___
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] Content-Disposition is driving me batty

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 9:54 am, Brian Sullivan wrote:

 I am running IE7 beta 3 -- on my machine the pdf file seems to load --
 so no content disposition problem but there are messages about missing
 fonts from the PDF reader *7.0.8 btw) -- no real information is
 displayed so I am guessing this is abnormal by your definition.

Nuts.  I was trying to generate a clean PDF for testing purposes but looks 
like it didn't work.  I re-uploaded the test file (same URL) with Times New 
Roman and embedded fonts.
-- 
Kirk Strauser
The Day Companies
___
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] Content-Disposition is driving me batty

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 11:02 am, Brian Sullivan wrote:

 OK -- that seems to be more what I would call normal. I see the page
 with This is a test in Adobe reader -- but also a page/tab is
 created that is blank. Is that the problem?

Nope - customers are actually getting a single blank page and nothing else.  
We could live with a blank tab if that was the only problem.
-- 
Kirk Strauser
The Day Companies
___
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] Content-Disposition is driving me batty

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 11:24 am, Brian Sullivan wrote:

 It looks like you have changed to remove the Content-Disposition header?

 Now it comes up inline (I guess the default?).

No, it's still there (and still set to inline).  I did, however, follow 
David H's advice to add the Content-Length header.  Preliminary tests are 
very promising.
-- 
Kirk Strauser
The Day Companies
___
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] Python Scripts and HTML Forms

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 1:57 pm, Muk Yan wrote:

 Name:input type=text name:first_name

Make that:

   input type=text name=first_name

 DTML Method, process_this_form:
 dtml-call REQUEST.SESSION.set ('firstName', first_name)
 dtml-call this_is_a_python_script()

 and in the Python Script, this_is_a_python_script
 I use REQUEST.SESSION.get('firstName')

Make that:

  dtml-call this_is_a_python_script(request['first_name'])
-- 
Kirk Strauser
The Day Companies
___
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] Python Scripts and HTML Forms

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 2:02 pm, Jens Vagelpohl wrote:

 request.get(MY_VARIABLE)  ???

The one major problem with that is that it ties you to getting information 
from the request.  Better to write a script with explicit parameters and 
call it with those parameters.  Then, you can pull values from a database, 
another Zope object, or anything else.  Also makes testing *much* easier 
(since you can use the Test tab to experiment with it).
-- 
Kirk Strauser
The Day Companies
___
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] Some users can't view sent PDFs anymore

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 2:39 pm, Gabriel Genellina wrote:

 This is unrelated to your main question, but using string exceptions
 is discouraged...

Yeah, I'm in the process of gradually upgrading from look at me, I'm 
learning Python! code to something a little more presentable.
-- 
Kirk Strauser
The Day Companies
___
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] Content-Disposition is driving me batty

2006-08-17 Thread Kirk Strauser
On Thursday 17 August 2006 1:28 pm, Dieter Maurer wrote:

 Your PDF file appears to be small.

It was pretty dinky earlier (a single line of text).

 I am also surprised that in your earlier post you returned
 the File object itself. I would rather expect
 str(fileObject.data).

Without looking at the source, I'm guessing that ExtFile.__repr__ just calls 
str() anyway.
-- 
Kirk Strauser
The Day Companies
___
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] Is ExtFile right for me?

2006-04-11 Thread Kirk Strauser
On Monday 10 April 2006 15:48, Jerry Westrick wrote:

 I'm currently using localFS and not only have problems with the missing
 properties, but the missing security access is more trouble some...

 I'd be interested to hear how the ExtFile went with you...

So far so good.  With a little help from Stefan Holek (thanks, Stefan!), my 
ZEO seems to be humming along nicely.  I'll keep you updated if anything 
major happens, but now that it's working I doubt that will occur.
-- 
Kirk Strauser
The Day Companies
___
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] Is ExtFile right for me?

2006-04-10 Thread Kirk Strauser
My Zope site generates many reports in PDF format, and stores them in a
folder that's only accessible to customers via a password-protected form.
I currently store each report's password as a property of its File object.

My problem is that I'm creating several hundred megabyte-sized file
objects in my ZODB each day, and even though I expire them after five
days the performance hit when storing and fetching the files is painful.

I think, then, that I should be looking at an external filesystem store.
LocalFS looks very nice, but it doesn't seem to support properties (which
I currently need).  ExtFile looks very nice and does support properties,
and that's the way I'm heading.  Does that seem reasonable given my usage?

Also, I'm currently inserting the file uploads into a folder named
files (ain't I creative?) with this method call:

context.files.manage_addFile(id=filename, file=filecontents, 
content_type=filetype)

I tried what I thought would be the ExtFile equivalent:

context.files.manage_addProduct['ExtFile'].manage_addExtFile(id=filename, 
file=filecontents, content_type=filetype)

but that only dumps the contents of the file to the client and doesn't
actually store that data.  Clients see a long page of gibberish like:

Shipment Search | View Selected Images 
%PDF-1.2 %âãÏÓ 1 0 obj  /Type /Catalog /Pages 3 0 R  endobj 2 0 obj  
/CreationDate (D:20060410110742) /ModDate (D:20060410110742) /Producer (libtiff 
/ tiff2pdf - 20060313 / d)  endobj 3 0 obj  /Type /Pages /Kids [ 4 0 R 9 0 
R ] /Count 2  endobj 4 0 obj  /Type /Page /Parent 3 0 R /MediaBox [0. 
0. 608.2560 792.] /Contents 5 0 R /Resources  /XObject  /Im1 7 0 R 
 /ProcSet [ /ImageB ]   endobj 5 0 obj  /Length 6 0 R  stream q 
608.2560 0. 0. 792. 0. 0. cm /Im1 Do Q endstream endobj 6 0 
obj 62 endobj 7 0 obj  /Length 8 0 R /Type /XObject /Subtype

In other words, the normal page header, plus the raw data.  I'm not sure
why that's happening.
-- 
Kirk Strauser
The Day Companies
___
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] Screwy permissions problem has me stumped

2006-03-24 Thread Kirk Strauser
On Thursday 23 March 2006 21:24, Andrew Milton wrote:

 Every TAL call pretty much creates a new security context, which is why
 it's hitting the DB so often (this is why it's best to turn on caching in
 XUF even for 5 or 10 seconds if you're using a 'slow' auth mechanism).

In the Paramaters tab in my XUF acl_users folder, I have:

  Credential Cache Timeout in Seconds (0 for No Caching) : 30
  Negative Credential Cache Timeout in Seconds (0 for No Caching): 5

and yet I'm still seeing several identical queries per second in my database 
logs.  Shouldn't those settings enable the cache?

 I'm not sure why it's using your username and not their own though,
 without actually looking at your setup. XUF just executes the lookups
 based on what Zope tells it to do.

Thanks.  I'll look into VerboseSecurity to see if I can figure out why it 
really, really wants to auth as me.
-- 
Kirk Strauser
The Day Companies
___
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: What's limiting my file uploads?

2005-12-30 Thread Kirk Strauser
On Thursday 29 December 2005 17:59, Florent Guillaume wrote:

 In your mail there's a method=post. You're sure you're actually
 executing this same code?

Absolutely positive.

 Otherwise no clue, I'd do a network trace to know what's really posted.

Will do.  I was hoping for an easy answer first.  :-)
-- 
Kirk Strauser
The Day Companies
___
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's limiting my file uploads?

2005-12-29 Thread Kirk Strauser
I have a very simple form on my site:

  table summary=Test form
  form action =receive997 enctype=multipart/form-data method=post
  trtdbUsername/b/tdtdinput type=text name=username 
size=16/td/tr
  trtdbPassword/b/tdtdinput type=text name=password 
size=16/td/tr
  trtdbFile/b/tdtdinput type=file name=contents size=30 
accept=*/*/td/tr
  trtd/tdtdinput type=submit value=Upload/td/tr
  /form
  /table

It posts to a trivial Python script:

  request = container.REQUEST
  return request

For testing purposes, the contents of username and password are six
bytes long.  As long as the file specified in contents is short (7843
bytes or less), the form section of the formatted request object looks
like:

  form
  username  'something'
  password  'password obscured'
  contents  ZPublisher.HTTPRequest.FileUpload instance at 0x91307ec

  cookies
  ...

As soon as the length of the submission crosses the 7843 byte barrier,
though, it becomes empty:

  form

  cookies
  ...

I can't figure out what's going on.  In zope.conf, cgi-maxlen is unset
(and therefore should default to zero).  http-header-max-length defaults
to 8192, which is pretty close to 7843 plus a little overhead, but the problem
remained even after I increased that value to 32768.

Any idea why Zope seems to be limiting my file upload size to this script to
just under 8KB?
-- 
Kirk Strauser
The Day Companies
___
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] Confusing DateTime().strftime behavior

2005-10-16 Thread Kirk Strauser
On Saturday 15 October 2005 01:24, Andreas Jung wrote:

 If you speak of DateTime instances then you should be able to write
 to two-line testcase that shows the issue with a standard Zope
 installation.
 If you can provide such a testcase we are able to look at it in detail.


date = context.testQuery()[0]['date']
print date
print date.ISO()
print date.strftime('%m/%d/%Y')
return


gives


2005/10/14
2005-10-14 00:00:00
10/13/2005


By the way, this is with Zope 2.7.7 and Python 2.3.5 on a FreeBSD 5-STABLE 
server (if that makes any difference).
-- 
Kirk Strauser
The Day Companies
___
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] Confusing DateTime().strftime behavior

2005-10-15 Thread Kirk Strauser
I'm upgrading our server from a FoxPro backend to PostgreSQL, using the 
Psycopg connector.  My problem is that the old database returned timestamps 
as a %m/%d/%Y-formatted string, while Psycopg returns a DateTime object 
(I'm using the internal module, not mxDateTime).  Whenever I use strftime 
to format the object for display, I get the previous day's date instead.

I've found several references to this problem in Google, but no one seems to 
have found a good solution.  Any thoughts?
-- 
Kirk Strauser
The Day Companies
___
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] Same product in multiple instances automatically?

2005-09-09 Thread Kirk Strauser
I'm running multiple instances of Zope 2.7.7 on a FreeBSD server.  Each of 
those instances uses the same products, which I handle by making symlinks 
from the site's Products directory to that instance's Products directory:

[1]  /usr/local/www/Zope/Products/ZPsycopgDA
[2]  /usr/local/www/Zope/Products/exUserFolder

 /usr/local/www/Zope/instance1/Products/ZPsycopgDA - [1]
 /usr/local/www/Zope/instance1/Products/exUserFolder - [2]

 /usr/local/www/Zope/instance2/Products/ZPsycopgDA - [1]
 /usr/local/www/Zope/instance2/Products/exUserFolder - [2]

 ...

To be honest, I'd expect something a little different, namely that each 
instance would automatically pull in all the products in the site 
installation (like [1] and [2] above), but that doesn't seem to be the 
case.  Is that a configuration issue, by design, or by accident?

It's not that I mind making a symlink here or there, but it's one more thing 
to remember when making a new instance and just feels wrong.
-- 
Kirk Strauser
The Day Companies
___
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] Same product in multiple instances automatically?

2005-09-09 Thread Kirk Strauser
On Friday 09 September 2005 10:25, Paul Winkler wrote:
  To be honest, I'd expect something a little different, namely that each
  instance would automatically pull in all the products in the site
  installation (like [1] and [2] above), but that doesn't seem to be the
  case.  Is that a configuration issue, by design, or by accident?

 It's a configuration issue.  Check out the products directive
 in zope.conf.

The one that says:

The master Products directory exists in Zope's software home, and
 cannot be removed from the products path (and should not be added to it
 here).

?  That seemed to me that I shouldn't be adding /usr/local/www/Zope/Products 
to the search path, although I'm unsure of the reasons.
-- 
Kirk Strauser
The Day Companies
___
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] Same product in multiple instances automatically?

2005-09-09 Thread Kirk Strauser
On Friday 09 September 2005 13:56, J Cameron Cooper wrote:

 I don't know why, either. That simply says that there is a default
 Products directory ($SOFTWARE_HOME/lib/python/Products), you can't get
 rid of it, and you shouldn't try to configure it here.

The problem I'm having, though, is that those products don't seem to be 
present in instances by default, which is the opposite of what I'd expect.  
For example, I'd think that ZPsycopgDA would be available inside each 
instance since it's present in $ZOPE/Products.

 If you want your instances to use Products from some other directory,
 name it here.

Yep.  I'm wondering if I should create a $ZOPE/CommonProducts directory and 
add products $ZOPE/CommonProducts to every instance's zope.conf.
-- 
Kirk Strauser
The Day Companies
___
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] Same product in multiple instances automatically?

2005-09-09 Thread Kirk Strauser
On Friday 09 September 2005 15:37, J Cameron Cooper wrote:

 Anything in $SOFTWARE_HOME/lib/python/Products is available in any
 instances that use that SOFTWARE_HOME. You can see this quite easily by
 looking at the /Control_Panel/Products of an instance with nothing in
 its $INSTANCE_HOME/Products.

 I'm not sure what you mean by $ZOPE/Products.

OH!  I see what you mean.  $ZOPE is defined in $INSTANCE/etc/zope.conf.  In 
my case, it's set to /usr/local/www/Zope, and there's a Products directory 
inside it.  FreeBSD installs new products to that directory.  I hadn't 
noticed that there was also a /usr/local/www/Zope/lib/python/Products 
directory with different contents.

Problem solved, although I'm not sure why /usr/local/www/Zope/Products 
exists in the first place; maybe it was meant to be a symlink 
to ./lib/python/Products?  Anyway, I think I can figure it out from here.  
Thanks!
-- 
Kirk Strauser
The Day Companies
___
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] Same product in multiple instances automatically?

2005-09-09 Thread Kirk Strauser
On Friday 09 September 2005 15:59, J Cameron Cooper wrote:

 Thus was created the instance/software distinction. Everything needed to
 run Zope goes into the SOFTWARE_HOME; everything that defines a specific
 distinct instance goes into INSTANCE_HOME (3rd party Products, Data.fs,
 config files, logs, etc).

...and on FreeBSD, everything you install through the ports system gets put 
in a second directory inside SOFTWARE_HOME, distinct from the ones in 
INSTANCE_HOME, and is not included in running instances by default 
(regardless of what the 00readme-freebsd.txt in that directory says).

In other words, it seems to be a FreeBSD bug rather than a Zope bug, and I'm 
off to file a problem report so that it'll hopefully get fixed.  Thanks for 
the information that led to uncovering this little surprise.
-- 
Kirk Strauser
The Day Companies
___
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] Apache proxying multiple instances in subdirectories?

2005-09-08 Thread Kirk Strauser
Until yesterday, I'd been running one instance of Zope behind an Apache 2
proxy on a server, and I'd set up zope.mydomain to access the
management interface using this clause:

VirtualHost *:80
DocumentRoot /usr/local/www/htdocs/
ServerName zope.example.com
CustomLog /var/log/httpd/zope.example.com-access_log combined

RewriteEngine on
RewriteCond %{HTTP:Authorization}  ^(.*)
RewriteRule ^/(.*) 
http://localhost:8080/VirtualHostBase/http/zope.example.com:80/VirtualHostRoot/$1
 [P]
/VirtualHost

When I visit http://zope.example.com/manage, I get the ZMI page as
desired.  So far so good.  However, I recently added a second Zope
instance to that server, and now would like to remotely manage them using
URLs like http://zope.example.com/instance1/manage .  For the life of me,
I can't figure out how to change the RewriteRule to point to a subdirectory
on the zope.example.com site.  I know this should be easy, but I'm just not
getting it.  Any ideas?
-- 
Kirk Strauser
The Day Companies
___
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] Sending mail with attachments via Python

2005-05-03 Thread Kirk Strauser
I'm currently trying to replace a bit of DTML with a Python script.
Here's what I currently have:

dtml-sendmail mailhost=outboundserver
To: dtml-var recipientemail
From: dtml-var senderemail
Subject: dtml-var subject
dtml-mime type=text/plain encode=7bit

Attention dtml-var recipientname:

This file was sent to you from the Foo Company web site.

The sender included this message:

dtml-var emailbody

dtml-boundary type=application/octet-stream disposition=attachment 
encode=base64 filename_expr=filenamedtml-var 
expr=publicstore.download(filename=filename,password=password,skipctypeheader=1)/dtml-mime
/dtml-sendmail

Basically, it fetches a file from a public download directory, encodes it
as a MIME attachment, and sends the works to the specified recipient.  Now,
the documentation on sending a normal text email is easy enough to find,
but from Googling around for more advanced docs it seems like I'm the only
person to ever want to do this.  Are there any examples for this sort of
thing lying around that I somehow managed not to find?

Many thanks,
-- 
Kirk Strauser
The Day Companies
___
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] Sending mail with attachments via Python

2005-05-03 Thread Kirk Strauser
On Tuesday 03 May 2005 15:30, J Cameron Cooper wrote:

 Look at the Python 'email' package:
 http://python.org/doc/lib/module-email.html

 You'll need to use External Methods to use this module, or allow access
 to it so that you can use Python Scripts.

That's what I was afraid of.  I love Zope and Python (and am getting ready 
to write a magazine article about the two) but jumping through Pythonic 
hoops to do stuff that would be easy in DTML drives me nuts.

Thanks for the pointer, though.  I'd stumbled across that earlier, but had 
kept looking in search of something easier.
-- 
Kirk Strauser
The Day Companies
___
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] Sending mail with attachments via Python

2005-05-03 Thread Kirk Strauser
On Tuesday 03 May 2005 16:09, J Cameron Cooper wrote:

 So you have it in DTML and want to re-write in Python but you don't want
 to do it in Python?

No.  I have it in DTML and want to re-write it in Python without involving 
External Methods or other hackery.  

 Then why change it? It works, right?

For certain values of works, sure.  The problem I'm trying to solve is 
that the body of the email needs to become more complex than I'm willing to 
handle with DTML.  The natural next step for me was to look into rewriting 
the whole mail-sending object in Python, but I didn't expect that I'd have 
to reimplement the functionality of DTML to do it.

Please don't misunderstand me.  I'm not complaining, and if that's what I've 
got to do then so be it.  I'm just a little surprised - that's all.
-- 
Kirk Strauser
The Day Companies
___
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] Both tal:on-error and error_log?

2005-04-18 Thread Kirk Strauser
Can I use a tal:on-error attribute in a page template to provide a 
user-friendly explanation of an exception while still recording the 
occurrence of that exception to error_log?
-- 
Kirk Strauser
The Day Companies
___
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] Both tal:on-error and error_log?

2005-04-18 Thread Kirk Strauser
On Monday 18 April 2005 13:35, Jens Vagelpohl wrote:

 I don't think that's possible. But you can test that very easily for
 yourself by putting code inside the on-error that provokes an error.

I guess I should've prefaced my question by saying that I know on-error 
normally ends propagation of the exception.  I guess I was wondering if 
there was some way to manually add the exception to an error_log object so 
that i can come back later to analyze that logfile, while still presenting 
a non-confusing error screen to my users.
-- 
Kirk Strauser
The Day Companies
___
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 )