Re: [Zope] Zope and wxPython interface

2009-08-13 Thread Jim Washington
Lumír Jasiok wrote:
 David Bear wrote:
 What do you gain by doing this?

 On Wed, Aug 12, 2009 at 2:50 PM, Lumir Jasiok lumir.jas...@vsb.cz
 mailto:lumir.jas...@vsb.cz wrote:

 Hi,

 I need to write an application which will be based on MVC design and
 will have both web interface and desktop GUI based on wxPython. It is
 possible to write such an application as standard Zope app and use
 zope.interfaces package for defining wxPython GUI as other view
 (I hope
 that it's called view, I am not sure - I am new in Zope
 programming)? Or
 am I totally wrong?

 Best Regards

 Lumir Jasiok

 --
 Lumír Jasiok
 VSB-TU Ostrava - Computer centre
 Tel: +420 59 732 3189
 E-mail: lumir.jas...@vsb.cz mailto:lumir.jas...@vsb.cz
 http://www.vsb.cz



 I want to have an application with common code for both web and
 desktop application, so data and business logic will be common and
 only thing which will be different will be a view (web page or desktop
 application GUI). So users will have choice what interface they want
 to use, data will be same.

 As programmer I want to have common code for business logic, because
 of simplicity. I don't want to have two trunks, two business logics etc.

Hi, Lumir

You might take a look at pyjamas (http://pyjs.org).  Using pyjamas, you
can have common code for business logic and also for the GUI on web and
desktop.  The main data transfer/persistence mechanism in pyjamas is
JSON-RPC, so that part of the model can be zope or anything that can do
JSON-RPC. 

If you like wxPython GUI code, pyjamas code is very similar, and there
are examples using PureMVC (http://puremvc.org) in the repository. 

You cannot, at present, use zope.interface to do automatic widget
generation in pyjamas. On the other hand, it is really easy to do custom
widgets and client-side display logic.  You write your widgets and their
behavior in python, not in HTML and javascript.  Styling, however, can
be done with css.

In the eight months since I first experimented with pyjamas
(http://www.mail-archive.com/zope@zope.org/msg31618.html), it has
improved substantially.  Fewer gotchas. More joy.  Worth a look.

- Jim Washington






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


Re: [Zope-dev] z3c.jsonrpc relase

2009-02-24 Thread Jim Washington
Roger Ineichen wrote:

 does someone have a good idea how we can handle an
 Unauthorized error with JSON-RPC? Should we use an error
 view concept and include a JavaScript method which can handle
 a special error code/message from the server and show a kind
 if login form?
 
 Any hints or does somebody know a framework which supports such 
 an implementation?

Hi Roger

Here's a hint I've been looking at.  Maybe it will give you some ideas.

http://ajaxpatterns.org/Direct_Login


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


Re: [Zope] Experiment: Pyjamas with Zope

2008-12-22 Thread Jim Washington
Quick note.

I found that The fix pyjamas question in my previous note could be 
handled with a ~100 line python module that makes a new class descending 
from pyjamas.HTTPRequest.HTTPRequest, but overriding asyncPostImpl with 
a supported content-type, e.g., application/json.

The module is mostly copy-paste from pyjamas.JSONService and 
pyjamas.HTTPRequest, but I'll provide it to anyone interested.  It was 
really simple to do.  Kudos to pyjamas for making fixes easy.

- Jim Washington
___
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] Experiment: Pyjamas with Zope

2008-12-20 Thread Jim Washington
So, I have a need to put together a more elaborate web page.  Lots of 
pop-up dialog boxes and dynamically-updated choice lists.  How to do that?

I take a look at Pyjamas http://pyjs.org. Pretty cool.

Here's the theory.  Write fancy application web page in python using the 
Pyjamas/GWT API, then compile it to javascript.  Serve it through 
zope, which will handle auth/auth.  Client-server communication flows 
through json-rpc calls.  What could possibly go wrong?

First-off, just a simple test-of-concept.  Edit the JSONRPCExample.py 
file in the examples/jsonrpc folder that came with pyjamas.

I'll locate the jsonrpc service in zope's containment root, so I change 
the uri in EchoServicePython from /services/EchoService.py to /. 
That's all I need to change.  Compile it using the handy build.sh 
that's in the same folder.  Look in the output folder and see what we got.

Wow. a bunch of files.

JSONRPCExample.IE6.cache.html
Mozilla.cache.html
OldMoz.cache.html
Opera.cache.html
Safari.cache.html
JSONRPCExample.html
JSONRPCExample.nocache.html
corner_dialog_bottomleft.png
corner_dialog_bottomleft_black.png
corner_dialog_bottomright.png
corner_dialog_bottomright_black.png
corner_dialog_edge.png
corner_dialog_edge_black.png
corner_dialog_topleft.png
corner_dialog_topleft_black.png
corner_dialog_topright.png
corner_dialog_topright_black.png
history.html
pygwt.js
tree_closed.gif
tree_open.gif
tree_white.gif

I'm lazy, so instead of doing a bunch of resource or view directives in 
ZCML, I let my paste.ini do the handling.

[app:pyjs1]
use=egg:Paste#static
document_root=/home/jwashin/projects/pyjamas/pyjamas-0.4/examples/jsonrpc/output

then, I link that in with the composite app.

[composite:Paste.Main]
use = egg:Paste#urlmap
/ = zope
/images = images
/pyjs1 = pyjs1

Now, to get to JSONRPCExample.html, I need to go to 
http://website/pyjs1/JSONRPCExample.html

But first, I need to actually handle the json-rpc requests in zope.

Make a servicetest.py.  Almost exactly similar to EchoService.py in the 
output/services folder.

from zif.jsonserver.jsonrpc import MethodPublisher
class Services(MethodPublisher):
 def echo(self, msg):
 return msg
 def reverse(self, msg):
 return msg[::-1]
 def uppercase(self, msg):
 return msg.upper()
 def lowercase(self, msg):
 return msg.lower()

Now, a ZCML incantation.

jsonrpc:view
 for=zope.app.folder.interfaces.IRootFolder
 permission=zope.Public
 methods=echo reverse uppercase lowercase
 class = .servicetest.Services
 /

Start zope, and go to http://website/pyjs1/JSONRPCExample.html

Nice page.  Click the Send to Python Service button.

Server Error or Invalid Response: ERROR 0 - Server Error or Invalid Response

Damn.

Pull up tcpwatch and see what we are getting.  Aha.  pyjamas app is 
sending jsonrpc with a content-type of 
application/x-www-form-urlencoded, so zope is not handing it off to 
zif.jsonserver for handling.

Fix pyjamas or let zif.jsonserver handle this content-type?

In zif.jsonserver's configure.zcml, in the publisher directive, add 
application/x-www-form-urlencoded to mimetypes.

Restart zope. Go to http://website/pyjs1/JSONRPCExample.html

It works.

Change permissions in the jsonrpc:view directive.  Restart zope.

Go to the page.  Page loads.  Push the button, and I get a Basic HTTP 
Authentication dialog.  Nice.

Overall Results:  So far, so good. :)

- Jim Washington

___
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] zip files corrupted with IE when opened, fine when downloaded

2008-03-17 Thread Jim Washington

robert rottermann wrote:

Hi there,
we have a problem with an intranet that runs using plone 2.5.3

when users using IE want to open a zip file from the intranet by using
the open option from the download dialog they get winzip complaining
that the file is corrupted.
if they select save from the same dialog they can open the zip archive
without problem.

does anyone know a solution for this or give me an idea where to look
for one?
  
I had a similar problem with pdf files, and googling indicated that IE 
might be deleting the cached copy of the document before the opening 
application can get to it.


I have had some success setting cache control to private.  Something like:

request.response.setHeader('cache-control','private')

private,must-revalidate may also be a good value, depending on your 
situation.


It's worth a try...

- Jim Washington

___
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] zip files corrupted with IE when opened, fine when downloaded

2008-03-17 Thread Jim Washington

Jim Washington wrote:

robert rottermann wrote:

Hi there,
we have a problem with an intranet that runs using plone 2.5.3

when users using IE want to open a zip file from the intranet by using
the open option from the download dialog they get winzip complaining
that the file is corrupted.
if they select save from the same dialog they can open the zip archive
without problem.

does anyone know a solution for this or give me an idea where to look
for one?
  
I had a similar problem with pdf files, and googling indicated that IE 
might be deleting the cached copy of the document before the opening 
application can get to it.


I have had some success setting cache control to private.  Something 
like:


request.response.setHeader('cache-control','private')

private,must-revalidate may also be a good value, depending on your 
situation.


I Googled back through and found that the problem usually manifests when 
you have a 'cache-control':'no-cache' header.  The above explanation was 
not quite right.


Anyway, either removing the no-cache header or using one that allows 
the local machine to keep a copy should work, if the problem is in fact 
a 'no-cache' header.


- Jim Washington
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope-dev] Zope 3 without ZODB

2008-02-15 Thread Jim Washington

Kapil Thangavelu wrote:
try ore.wsgiapp in pypi, you provide a root utility and traversal 
begins from there, the zodb is never opened. the default publication 
looks up the app root via utility and traversal continues from there. 
i've been using it successfully for a number of relational apps 
without the zodb.

Thanks, Kapil.

I spent a day on it, and never got past error pages.  Maybe my problem 
was starting with a zopeproject.


Anyway, it got me to take a good look at pylons, which I think is a 
better match for web development without ZODB.


I found I can still use adapters and utilities by using zope.component 
and zope.interface. :)


zif.sedna (newly beta2 in pypi) now has instructions for using its zope3 
database adapter with repoze.tm in pylons.


- Jim Washington
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )


[Zope] ANNOUNCE: zif.sedna-0.9beta

2008-02-07 Thread Jim Washington
The Zif Collective is proud to announce yet another confusing option for 
your applications.


Sedna is a native XML database, open source, licensed under Apache 2.0 
license.


See http://modis.ispras.ru/sedna/ for features and download.

zif.sedna communicates with Sedna.

zif.sedna provides a dbapi-like interface (connections and cursors).

zif.sedna provides a zope(3) database adapter and connection pooling 
(thanks to some code from sqlalchemy).  It is provisionally thread-safe.


zif.sedna is pure python.

XQuery can be cool.

zif.sedna is now available at the cheese shop.  
http://pypi.python.org/pypi/  The readme came out a bit funny there.  I 
know there were some  and  in the document when I wrote it, so you 
will have to use your imagination a bit to read the blurb.  Or 
easy_install it and read the docs as they were intended.


-Jim Washington
___
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] suddenly confused

2008-01-18 Thread Jim Washington
David Bear wrote:
 I'm doing my first zeo setup, and suddenly I'm not sure about my
 products directory. Do I put all products in a products directory of
 the zeo server or in each zope instance?

   
IIRC, Products go in each zope instance.  The zeo instance gets the ZODB.

-Jim Washington
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope-dev] Zope 3 without ZODB

2008-01-15 Thread Jim Washington
David Pratt wrote:
 Hi Chris. I was scanning the lists looking for posts similar to this.
 Were you successful in getting something like this to work? Anyone
 else document anything like this?

 I wrote a different main.py at some point about a year or so ago so
 both twisted clients and servers to could be started up using schemas
 for zconfig but am looking at possibilities without and with other non
 ZODB backends. I see Philip provided some clues for a mixin that could
 be used to glue the publisher's traversal mechanism together with an
 alternative storage.  Many thanks.

 Regards,
 David
I, too, am interested in this.

I'm taking a hard look at Sedna, http://modis.ispras.ru/sedna/ , a
multi-user XML database, which seems to fit my brain and my current
xml-ish bent a bit better than ZODB or rdb.

The python modules advertised don't work reliably enough for me, though
I have hacked together a protocol module that works to my satisfaction
so far.  If anyone wants to play with it, I'll throw it into the zif
collective on Sourceforge.  I'm thinking it may be possible to do an
elementtree (with full XPath!) interface to Sedna.

Anyway, Chris, any pointers on interfaces and configuration would be
very much appreciated.

-Jim Washington




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


Re: [Zope] Import Modules

2006-06-23 Thread Jim Washington
Luiz Fernando B. Ribeiro wrote:
 Hello,

 I manage my own servers developing web applications and I would like
 to remove the import restrictions of python modules in python scripts.
 Is it possible? How can I allow other modules to be imported? I have
 been using external modules but it is starting to become nonproductive
 since I have to create functions to simple problems like md5, re, etc,
 and just using the needed modules would be much simple.

 I use Zope as an application server and my clients do not have access
 to the ZMI, so I'm not concerned with protection against misuse by my
 clients.

 Thanks in advance,

I recall seeing some documentation about this use case somewhere.  I
think it was in the folder with the python scripts product.

-Jim Washington
___
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] AJAX and Zope

2006-05-24 Thread Jim Washington

Lennart Regebro wrote:

On 5/24/06, Pascal Peregrina [EMAIL PROTECTED] wrote:

By Zope objects I meant:

You've got a page template for example, and you include such an AJAX 
enabled object, basically rendering an HTML fragment, and the 
resulting page will include the page template code + the fragment 
(similar to a macro call), but will also include the needed 
javascript code to handle the asynchronous communication.


That is a macro call. There is no difference. It just that the macro
includes the HTML needed to suck in the JS library you use.
I have been working on a simple WSGI middleware filter that handles js 
library insertion pretty well, without complicated macros that assure 
that a javascript library gets included only once. 

It works by creating a WSGI environ variable for desired includes.  
Individual widgets ask a utility to register their need for a particular 
javascript or css resource into that environ variable.


After Zope is finished generating the page, the middleware inserts the 
appropriate script and/or style tags into head before delivery to 
the client.


The current implementation works in Zope 3.  I have not experimented 
with Zope 2 on this, but it seems that with Zope 2's new 
WSGI-friendliness and Five, it is likely not too far from something 
usable in Zope 2.  The Zope 3 implementation needs zope.paste and 
paste.deploy.  The middleware app itself should work for anything WSGI.


Code (Due credit: the Zope 3 infrastructure for this borrows heavily 
from zc.resourcelibrary) and instructions are at 
http://zif.hill-street.net/headincludes  Development status: works for me.


This is just a small piece of the AJAX puzzle for Zope, as I see it.

-Jim Washington

___
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] REMOTE_USER Security Issue

2006-05-18 Thread Jim Washington

Cliff Ford wrote:
This is just to report that this issue is resolved (for me). Tres 
Seaver kindly provided a patch for HTTPRequest.py that makes the 
environ dictionary immutable (appended below for those in a similar 
position). This may have adverse consequences for applications that 
rely on existing behaviour and Tres has recommended that it would be 
better to harden the User Folder code. In our case we might also be 
able to encrypt the remote Username. Once again, thanks to Tres and 
other list members, who are a wonderful resource.
Completely immutable environ is not a good choice from WSGI 
point-of-view.  environ can be useful for middleware information-passing.


-Jim Washington

___
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] REMOTE_USER Security Issue

2006-05-18 Thread Jim Washington

Lennart Regebro wrote:

On 5/18/06, Jim Washington [EMAIL PROTECTED] wrote:

Completely immutable environ is not a good choice from WSGI
point-of-view.  environ can be useful for middleware 
information-passing.


WSGI middleware would by definition get the environ and be able to
modify it before the request gets it, so that isn't a problem.

Yes, not a problem for for middleware - app communication.  But some 
app - middleware communication would be impossible if environ is 
completely read-only.  I am assuming that immutable here means 
read-only.


What if a middleware app puts a key in environ specifically for the app 
to write e.g., post-processing parameters?  I have a use case for that.


-Jim Washington
___
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 installation glitches

2006-04-17 Thread Jim Washington

Andrew Sawyers wrote:

I've not experienced any build problems running on 64bit machines.  I've
got a 64bit laptop and 64bit dev desktop machine, not to mention all our
production servers are 64bit as well.

  

I've seen the same lib/lib64 problem in Gentoo Linux on Zope 3.

To work-around the problem, I make a symlink from lib to lib64 after 
install, and things work OK.


-Jim Washington


___
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 installation glitches

2006-04-17 Thread Jim Washington

Andrew Sawyers wrote:

I'm running Suse 10 - and I've got both /usr/lib and /usr/lib64
I don't believe that dependency has anything to do with  Zope.

  
If I take the zope distribution tarball and do the configure, make, make 
install dance, I get a 'lib64' directory inside the Zope installation 
instead of a 'lib' directory. 

mkzopeinstance has trouble with that configuration.  It needs a 'lib' 
directory instead of a 'lib64' directory, so mkzopeinstance fails unless 
I do something, like symlinking lib64 to lib.


-Jim Washington

___
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: Re: ZAjax anyone?

2005-10-11 Thread Jim Washington

Greg Fischer wrote:


Ah even better!  Thanks guys.

I was going to reply just to mention I have a not as cool way of 
using Zope with Ajax at my site now too.


www.zajax.net http://www.zajax.net/

Seems every rock I turn over, I find 3 others worth investigating.  
Lots of cool stuff going on out there.  I put up my own demo, but it's 
not nearly the prefered way of doing things by most people.  I myself, 
prefer DTML over ZPT, so my demo is based on that.  I also am using 
one of the larger client frameworks available, Dojo Toolkit.  The js 
file is around 130k if I remember.  The smaller ones are great and do 
the job, but I wanted something larger and more widely used like Dojo 
to build off of.


I know eventually I'll look at the JSON stuff too.  Sound interesting.


Hi, Greg

Cool!  I like the way you do the how-to.  Do you plan similar how-tos 
for other JS libraries/techniques?  Would you accept contributions? I 
find myself looking at mochikit (http://mochikit.com) occasionally.  In 
its ajax-tables demo, it uses a tal(esque) syntax for dom manipulation 
in client javascript, which could be interesting for fans of page templates.


For the future, dare I ask, maybe some zope3 stuff?

I think the zope community really needs zope-oriented how-tos and 
evaluations of the various AJAX libraries.  zajax.net has the right name 
to be a prime focus of such activities, should you be willing to do that.


Thanks!

-Jim Washington

___
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 dump Zope database content into a file system directory tree?

2005-09-13 Thread Jim Washington

[EMAIL PROTECTED] wrote:


Possible to dump content in Zope database into a
file system tree?
 


Yes.

http://www.zope.org/Members/tseaver/FSDump

--Jim Washington
___
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] Puzzling Import/Export problem

2005-07-23 Thread Jim Washington

A friend in Russia is still using my old ZClasses QSurvey product.

He is attempting to copy an installation from one machine to another, 
and upgrade Zope to 2.6.4.


Exporting the product and instances works fine, but some object 
instances will not import correctly.


A product instance is a folderish object that contains other objects.  
One particular folderish subobject will not import correctly; all the 
others import fine.  The .zexp of the entire product instance, with 
subitems, etc., imports OK, but the one folderish object shows up as 
broken in the ZMI.


Exporting that object as XML and reimporting after correcting the 
appropriate class ID string results in a BadPickleGet error 7.


Traceback (innermost last):
 Module ZPublisher.Publish, line 113, in publish
 Module ZPublisher.mapply, line 88, in mapply
 Module ZPublisher.Publish, line 40, in call_object
 Module OFS.ObjectManager, line 561, in manage_importObject
 Module OFS.ObjectManager, line 578, in _importObjectFromFile
 Module ZODB.ExportImport, line 65, in importFile
 Module OFS.XMLExportImport, line 119, in importXML
 Module ZODB.ExportImport, line 75, in importFile
 Module transaction._transaction, line 368, in commit
 Module transaction._transaction, line 297, in savepoint
 Module transaction._transaction, line 294, in savepoint
 Module transaction._transaction, line 656, in __init__
 Module ZODB.Connection, line 1034, in savepoint
 Module ZODB.Connection, line 470, in _commit
 Module ZODB.ExportImport, line 140, in _importDuringCommit
BadPickleGet: 7


I have examined the xml export, and the only thing I can think of that 
might be a problem is that some of the object IDs for some contained 
items are base64-encoded and may contain Russian characters.  But that 
does not seem to be the problem, since a similar, smaller import with 
only ascii characters fails with the same traceback and BadPickleGet:10.


I realize that this might be an uninteresting edge-case.  My backup plan 
is to write a script to pull the data out of the XML export and recreate 
the objects.  Does anyone have any pointers on that?  I am having 
trouble figuring out how that file is organized.


For completeness, I am using zope-2.8.0, but this happens on 2.7.6 as well.

-Jim Washington
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope-dev] Zope on 64-bit Linux

2004-11-19 Thread Jim Washington
Larry Bates wrote:
Anyone out there successfully deploying and running Zope/CMF
on 64-bit Linux?  I'm looking at deploying AMD Opteron server
for hosting large Zope site and wanted to take advantage of
the speed and addressing capabilities if I could.  Specifically
I'd like to use RedHat Fedora Core 3 to run ZODB server and
ZEO Clients.  Any information would be greatly appreciated.
I have had success with zope2 and zope3 under 64-bit Gentoo Linux (2.6+) 
on a dual-Opteron box, but, of course, everything was compiled locally.

I suppose that this just means that it probably should work in Fedora 
Core 3.  I have no experience with Fedora, but it is probably worth a 
try.  I did not have to do anything special.

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


[Zope-dev] 501 NotImplemented in Zope 2.7 beta1

2003-08-15 Thread Jim Washington
I have been noticing a few 501 Not Implemented errors in the ZMI in 
2.7 beta.

The ones I have encountered are fixed by changing method=get to 
method=post in the html/dtml forms in e.g., Aqueduct.py.

I do not know the proper fix.
Also, this is weird enough (and perhaps merely a beta issue) that I 
could not decide the proper category in the bug collector or even what 
to search on to see if it had been reported previously.

So, consider this an FYI should anyone want to take a stab at fixing it 
or reporting it to the collector.

-- Jim Washington

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


Re: [Zope-dev] robustness in management interface.

2003-02-07 Thread Jim Washington
Romain Slootmaekers wrote:


Hi,

The zope management interface has some robustness problems:

whenever you call manage_workspace (the normal way of managing a 
folder through the HTML Zope management interface) on a folder X, and 
some object y in that folder gives an error (fi, it has no title 
attribute, ) the whole folder becomes unmanageble. The only thing you 
can do at that point is to manually delete the problematic object by 
typing:

http:///X/manage_delObjects?ids=y

It seems to me that an object in a folder should not interfere with 
the management of the folder (at least, you should be able to throw 
the object out of the folder)


probably, a try/except or dtml-try in the right place fix this.


Or, you could assure that your objects all have titles (at least =) if 
you want them managed through the ZMI.  I have not seen this as a 
*requirement*, but every example of a zope object I have seen uses 
self.title=aString in __init__().  

It is also important to have titles for most cataloging.  Do you catalog 
your site?  Is not title a good thing for searching?  Might you catalog 
in the future?

Perhaps something for a BestPractices document(?) or wiki(?):

ZMI-manageable objects have a title attribute.  This is a string.

For a bit of context on the above, I put together a product that has 
title as a function (=[:30] of some content) some time ago.  I have been 
led to understand that this was a bad idea because it breaks some 
cataloging.

Your idea of dtml-try does have merit IMHO.  Should the ZMI really 
assume existence of anything other than id for objects?

-- Jim Washington


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


Re: Support for X-HTTPD-FORWARDED-FOR Re: [Zope-dev] Speaking of2.6...

2002-04-11 Thread Jim Washington

Toby Dickenson wrote:

On Wed, 10 Apr 2002 12:16:35 -0400, Jim Washington [EMAIL PROTECTED]
wrote:

2.  If we want to get fancy about allowing authentication using that ip 
address like naked ZServers can do,


to

if request.has_key('HTTP_X_FORWARDED_FOR'):
  addr=request['HTTP_X_FORWARDED_FOR']
   elif request.has_key('REMOTE_ADDR'):
  addr=request['REMOTE_ADDR']


There are lots of things that use REMOTE_ADDR, and I guess they should
*all* use the proxy supplied address rather than the address of the
proxy. It makes sense to me that we should *replace* REMOTE_ADDR with
HTTP_X_FORWARDED_FOR at the earliest opportunity. (and create a
X_FORWARDED_BY)

Have you considered this approach?

Not yet, but I like the idea...  As with Oliver's reply, this I think 
would need some research.  I will be refining what I mean by support 
in the subject line shortly.



On Wed, 10 Apr 2002 18:59:38 +0200, Oliver Bleutgen [EMAIL PROTECTED]
wrote:

Correct me if I'm wrong, but this IMO makes spoofing against a naked 
ZServer a childs play.


Thats correct for a naked ZServer, or if behind a proxy which does not
sanitize the X-FORWARDED-FOR header. However it is safe if the request
comes from the right kind of proxy.

I think we need a new command line option to specify a list of IP
addresses which are trusted to run 'the right kind of proxy'. Zope
should only trust the X-FORWARDED-FOR header if the remote address is
one of its trusted proxies.

Pseudocode for handling this would be:

if request['REMOTE_ADDR'] in our_trusted_front_end_proxies:
request['HTTP_X_FORWARDED_BY'] = request['REMOTE_ADDR']
request['REMOTE_ADDR'] = request['HTTP_X_FORWARDED_FOR']

Excellent!  Except for command-line bloat.  With Matt Behrens's config 
proposal 
(http://dev.zope.org/Wikis/DevSite/Proposals/InstallationAndConfiguration), 
this nevertheless could be workable.  Things are looking up.  Maybe. 
 U..., more research...

-- Jim Washington



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



Support for X-HTTPD-FORWARDED-FOR Re: [Zope-dev] Speaking of 2.6...

2002-04-10 Thread Jim Washington

Support for X-HTTPD-FORWARDED-FOR

Code for this is pretty simple:

modify 2 files, ZServer/medusa/http_server.py and 
lib/python/AccessControl/User.py

1.  To put the proxy-passed ip address in the zserver log,

Around line 269 in ZServer/medusa/http_server.py, add a method 
http_request::client_ip

def client_ip(self):
proxy_client = self.get_header('x-forwarded-for')
if proxy_client:
return proxy_client
else:
return self.channel.addr[0]

Then around line  294, change the statement that does logging to use the 
method.
self.channel.server.logger.log (
self.client_ip(),
' - %s [%s] %s %d %d %s %s\n' % (
name,
...

2.  If we want to get fancy about allowing authentication using that ip 
address like naked ZServers can do,

In lib/python/AccessControl/User.py, around line 1116,
change

if request.has_key('REMOTE_ADDR'):
   addr=request['REMOTE_ADDR']

to

if request.has_key('HTTP_X_FORWARDED_FOR'):
   addr=request['HTTP_X_FORWARDED_FOR']
elif request.has_key('REMOTE_ADDR'):
   addr=request['REMOTE_ADDR']

I do not believe this does anything to authentication that is not 
possible now regarding spoofed ip addresses, so probably not a major 
security headache.

Major possible problem I can think of:  I do not use ZEO, and have no 
idea what these changes might do there.  I do not have check-in 
privileges, and probably should not until I get a better clue of how cvs 
works :).

Anyway, here is the code FWIW.  Apologies that it is not a patch per se. 
 Now looking for a more clueful sponsor to take it from here to check-in 
(after vetting?)

-- Jim Washington

Brian Lloyd wrote:

...I sent out a note a while ago now trying to scare up 
some ideas on how to vet the current list of 2.6 proposals 
and get to a final plan. I didn't get much (any?) response :(

For a couple of things that were ready to go and fairly non
controversial (like Toby's unicode work), I put on the BDFL 
hat and said merge it!.

But there are still a lot of things on the proposed features 
that are undone, and some that are controversial enough that 
we need to get to closure on them.

I'll volunteer to convert the current proposed feature list 
into a draft plan, where the conversion boils down to 
adding some columns to the table:

Proposal - name and link to the proposal

Resources - who is working on it

Committed - Y/N whether the volunteers have committed to have
the implementation and docs done by the first week
in June. I'll fill in what I know has been committed
to, people can update this (or let me know and I'll 
do it), and anything that doesn't get a 'Y' in a 
reasonably short time will be put in the cooler.

Vetted - Y / N whether the community and / or the relevant BDFLs
 have come to some agreement on whether it *should* be 
 done. The list of items without a 'Y' will be our next 
 order of business. Getting to closure on those either 
 via the list, IRC, or whatever is the main block on the 
 critical path.

Status - Complete or incomplete 


I've taken a first stab at this. I've set the committed to 'Y' 
for those things that I know I've gotten commitments for. For 
those set to 'N', please let me know if you can commit to the 
date (or change it yourself in the wiki).

The updated plan is at:

http://dev.zope.org/Wikis/DevSite/Projects/Zope2.6/ProposedFeatures


Once we get the commitments up to date, we can start wrangling 
with the vetting...





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



Re: Support for X-HTTPD-FORWARDED-FOR Re: [Zope-dev] Speaking of2.6...

2002-04-10 Thread Jim Washington



Correct me if I'm wrong, but this IMO makes spoofing against a naked 
ZServer a childs play. It's just adding a custom header to the request.
I also doubt that every reverse proxy overwrites this header, so 
zservers behind a proxy might also be hit.


Note:  this is using another web server to front for zope.  It turns out
to be fairly safe -- I have used a variant for quite a while and did
quite a bit of testing.  For short hand, I am going to call the other web
server apache.  Apache presumably uses something like getpeername to
fill in its idea of HTTP_X_FORWARDED_FOR or REMOTE_ADDR.  If the remote
user attempts to spoof it (by using hidden variables, or other HTTP
based techniques), the Zope server interprets this is a list, rather
than the expected string.  This is easy to detect, and in fact, if you
fail to handle it, you will probably simply error out.

If the attacker is using TCP spoofing, there is really not much you can
do at an application level.

On the other hand, I am now conviced that this is not an intelligent
thing to do, not even for presentation.  You already have Apache in
front, so why not use rewriting rules to make the URL distinguishable.
In this way, you can use one of the BASE or URL variables to determine
how the person got in.  This gives you pretty much the same level of
control (especially if you are worried only about internal/external) as
using IP addresses, without modifying either Zope or Apache.

Jim, Oliver

Thanks. I'm glad we have smart and knowledgeable people available to 
discuss these kinds of things.  My hope was that I could restrict my 
Manager account to a short list of machines, even through a squid or 
apache proxy.  Essentially add a third thing to have besides username 
and password.  Which I still think is better than just username and 
password, since Zope sees only *one* ip address coming from squid in the 
current situation.  I'll have to do some more thinking...

Regards,

-- Jim Washington



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



Re: [Zope-dev] more on the segfault saga

2002-03-14 Thread Jim Washington

Don't know if this helps, but the last three segfaults I have seen were 
right after someone logs in, during loading /manage.

Zope-2.5.0 Win32 binary on Win2k. The pop-up referenced the same 
instruction 0x1e13490a at the same memory address 0x005c all 
three times, saying 'memory could not be read.'

-- Jim Washington


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



[Zope-dev] More Zope 2.6 requests

2002-03-08 Thread Jim Washington

While we are asking, I have two things that I would consider valuable 
additions to Zope 2.6:

1.  UserSniffer.  Currently an External Method, but has functionality 
that should be available OOTB to assist making those (horrors!) 
browser-dependent hacks.  It has other uses, too, like explaining to 
clients that their browser is five years old and needs the free upgrade 
that is available.

2.  Support for HTTP_X_FORWARDED_FOR.  Many (most?) of us run zope 
behind Apache ProxyPass or Squid, and the Zope logs therefore save the 
ip address of the proxying machine rather than any semblance of where 
the client browser is.  I realize that other proxies do not always 
follow the rules, etc., etc., but I think that using 
HTTP_X_FORWARDED_FOR if not null would be better than a log full of 
192.168.1.1.

Apologies if these have already been discussed under another heading.

-- Jim Washington



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



[Zope-dev] [Fwd: Re: [Zope] Python 2.1 for debian ?]

2001-10-03 Thread Jim Washington


Would it be smart to include the python header files in the zope binary 
distributions?  That would seem to solve a few problems for the 
individuals using them.

-- Jim Washington

 Original Message 
Subject: Re: [Zope] Python 2.1 for debian ?
Date: Wed, 03 Oct 2001 12:51:37 + (GMT)
From: Julián Muñoz Domínguez [EMAIL PROTECTED]
To: Jim Washington [EMAIL PROTECTED]



Thank you very very much ;-)

But it is not possible to compile extensions with zope binary
distributions, because it lacks some headers. Many products requires
compiling extensions, so that readdress me to need of Python 2.1 . 






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



[Zope-dev] Where to send patches?

2001-09-10 Thread Jim Washington

Hi, All

Since the Collector is down, where do we send patches if we are not 
cvs-authorized?  I just discovered a not-too-clever hack to make the 
Find tab  recurse through methods of Z Classes, which the margin of this 
e-mail is too small to contain.

-- Jim Washington


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



Re: [Zope-dev] Where to send patches?

2001-09-10 Thread Jim Washington

Michel Pelletier wrote:

On Mon, 10 Sep 2001 12:16:51 -0400
 Jim Washington [EMAIL PROTECTED] wrote:

Hi, All

Since the Collector is down, where do we send patches if we are not 
cvs-authorized?  I just discovered a not-too-clever hack to make the 
Find tab  recurse through methods of Z Classes, which the margin of
this 
e-mail is too small to contain.


Dude, don't jinx yourself.  I'm sure you don't want us to refer to this as Jim 
Washington's last patch. ;)

Ack!  I deserve that for playing the cleverness card.  Fortunately, I am 
not planning any duels anytime soon :)

The requested change does seem to work, and does not seem to break 
anything.  And it is probably bad to admit that Z Classes are somehow 
different enough to require special treatment in base Zope code.  FWIW, 
 my patch (against FindSupport.py in 2.4.1) is attached.  Consume at 
your leisure.

-- Jim Washington


*** FindSupport.py.orig Mon Sep 10 11:31:20 2001
--- FindSupport.py  Mon Sep 10 11:55:19 2001
***
*** 152,168 
  if hasattr(obj, 'aq_base'):
  base=obj.aq_base
  
! if not hasattr(base, 'objectItems'):
  return result
  try:items=obj.objectItems()
  except: return result
  
  try: add_result=result.append
  except:
  raise AttributeError, `result`
  
  for id, ob in items:
! if pre: p=%s/%s % (pre, id)
  else:   p=id
  
  dflag=0
--- 152,179 
  if hasattr(obj, 'aq_base'):
  base=obj.aq_base
  
! if not hasattr(base, 'objectItems') and not base.meta_type == 'Z Class':
  return result
+ 
+ if hasattr(base, 'objectItems'):
try:items=obj.objectItems()
except: return result
  
+ if base.meta_type == 'Z Class':
+   try:items=obj.propertysheets.methods.objectItems()
+   except: return result
+ 
+ 
  try: add_result=result.append
  except:
  raise AttributeError, `result`
  
  for id, ob in items:
! if pre: 
!   if base.meta_type == 'Z Class':
! p = %s/propertysheets/methods/%s % (pre,id)
!   else:
! p=%s/%s % (pre, id)
  else:   p=id
  
  dflag=0
***
*** 194,201 
  ):
  add_result((p, ob))
  dflag=0
! 
! if search_sub and hasattr(bs, 'objectItems'):
  self.ZopeFind(ob, obj_ids, obj_metatypes,
 obj_searchterm, obj_expr,
 obj_mtime, obj_mspec,
--- 204,211 
  ):
  add_result((p, ob))
  dflag=0
! #small edit here to add the or
! if search_sub and (hasattr(bs, 'objectItems') or bs.meta_type == 'Z 
Class'):
  self.ZopeFind(ob, obj_ids, obj_metatypes,
 obj_searchterm, obj_expr,
 obj_mtime, obj_mspec,



Re: [Zope] Picture of the day product

2001-01-30 Thread Jim Washington

Hi, Tim

context.ZopeTime()

or 

container.ZopeTime()

ZopeTime is not in the PythonScript's namespace.  It is available in
most (all?) containers, however.  

-- Jim Washington


Timothy Wilson wrote:
 
 On Mon, 29 Jan 2001, Tres Seaver wrote:
 
   I'd like to grab all instances with a display_date = today's
   date. I can't figure out exactly how to do that in DTML or a
   Python Script. Once I have that list of instances, I'll simply
   pull off the latest one as you suggested.
 
  I don't know where it would be in the book it would be, but
  I do this something like::
 
dtml-in expr="theCatalog( meta_type='Photo'
 , display_date=ZopeTime()
 , display_date_usage='range:max'
 , sort_on='display_date'
 , sort_order='reverse'
 )"
 
  The expression would be basically the same in a PythonScript::
 
return context.theCatalog( meta_type='Photo'
 , display_date=ZopeTime()
 , display_date_usage='range:max'
 , sort_on='display_date'
 , sort_order='reverse'
 )
 
 Great! The first DTML example works perfectly. The second, however, throws
 up an error. In fact, I have yet to figure out how to use ZopeTime() in a
 PythonScript. Do I have to pass anything in?
 
 I get:
 
 Error Type: NameError
 Error Value: ZopeTime
 
 when I try it.
 
 -Tim

___
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] porting from Python Methods to PythonScripts in2.3.0;LoginManager too

2001-01-29 Thread Jim Washington

The text of an external method for converting Python Methods to Python
Scripts was posted to the list a while back.  I forget who because I
just copied and pasted at the time.  Anyway, credit to whoever, and
apologies for not having the name.

I took that and made something that works for me as a Python Script.
(Though my Methods have been rather simple...)

Standard caveats, YMMV, etc, but it does a quick pass on the Methods in
the folder where it is and makes Scripts from them when you hit the
'test' tab, saving the old ones as methodname.old.  It's not perfect
(e.g., it will import random if you use whrandom); it's just a bit
easier than manually editing (copy, paste, edit) for the same
functionality.  It would be pretty easy to recurse all folders and
change them all, but I am not that bold yet.  It seems debugged enough
to post.  I am sure someone will let me know if otherwise.  

-- Jim Washington

 begin code

import string
ids = container.objectIds('Python Method')
#what suffix do we want on the old Methods?
oldscriptsuffix='.old'
#replace all self. with the following:
#change to context if needed
newself = 'container'
#for future programmatic use just to be certain no extra dots
if string.find(newself,'.') = 0:
  newself = string.replace(newself,'.','')
for method_id in ids:
  method_id = string.strip(method_id)
#get the Method and its title
  method = container[method_id]
  title = method.title
#FTPget does not require external method!
  thebody = method.manage_FTPget()
#get the params
  eop = string.find(thebody,'/params')
  params = thebody[8:eop]
  params = string.replace(params,' ','')
  params = string.replace(params,'self,','')
  params = string.rstrip(string.replace(params,'self',''))
  body = thebody[eop+10:]
#get the body
  newbodylist = []
  splitbody = string.split(body,'\n')
#do imports as needed
#bug: random will be imported if you use whrandom
  for animport in ['string','whrandom','random','math']:
if string.find(body,animport+'.') = 0:
  newbodylist.append('import ' + animport)
  for k in splitbody:
#this would be a good place for re; put container where self was
newstring = string.replace(k,'self.',newself + '.')
#bug: might miss 'self [' wish re were available
newstring = string.replace(newstring,'self[', newself + '.')
newbodylist.append(string.rstrip(newstring))
  body = string.join(newbodylist,'\n')
# uncomment to see the raw data
#  print 'params = "%s"' % params
#  print 'body is:\n"%s"' % body
  
#rename the old and create the new.  don't do more than once.
  if method_id [-len(oldscriptsuffix):]  oldscriptsuffix:
container.manage_renameObject(method_id,method_id+oldscriptsuffix)
   
container.manage_addProduct['PythonScripts'].manage_addPythonScript(method_id)
newscript = container[method_id]
newscript.ZPythonScript_setTitle(title)
newscript.ZPythonScript_edit(params, body)
print 'converted: \t%s' % method_id

if len(printed)  9:
  print "No methods to convert"
return printed

 end code

Evan Simpson wrote:
 
 From: "Fred Yankowski" [EMAIL PROTECTED]
  + Don't copy over SiteAccess and PythonMethods.
  + Delete the PythonMethods product from the Control_Panel/Products
management folder.
 
  Will I have to manually convert each existing Python Method to
  a PythonScript, or are they essentially the same type?
 
 They are radically different types, and can therefore live in the same Zope,
 side-by-side, without conflicting.  There is no automatic conversion
 process.  Simply keep PythonMethods installed, and replace individual
 Methods with Scripts as you feel the need.

___
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] porting from Python Methods to PythonScriptsin2.3.0;LoginManager too

2001-01-29 Thread Jim Washington

Hi, Fred

I discovered another bug in it.  Where it changes stuff with "self[", it
changes it to "container.", which is wrong, but a simple edit.

new code:

import string
ids = container.objectIds('Python Method')
oldscriptsuffix='.old'
#replace all self. with the following:
#change to context if needed
newself = 'container'
#for future programmatic use just to be certain no extra dots
if string.find(newself,'.') = 0:
  newself = string.replace(newself,'.','')
for method_id in ids:
  method_id = string.strip(method_id)
#get the Method and its title
  method = container[method_id]
  title = method.title
#FTPget does not require external method!
  thebody = method.manage_FTPget()
#get the params
  eop = string.find(thebody,'/params')
  params = thebody[8:eop]
  params = string.replace(params,' ','')
  params = string.replace(params,'self,','')
  params = string.rstrip(string.replace(params,'self',''))
  body = thebody[eop+10:]
#get the body
  newbodylist = []
  splitbody = string.split(body,'\n')
#do imports as needed
#bug: random will be imported if you use whrandom
  for animport in ['string','whrandom','random','math']:
if string.find(body,animport+'.') = 0:
  newbodylist.append('import ' + animport)
  for k in splitbody:
#this would be a good place for re
newstring = string.replace(k,'self.',newself + '.')
#bug: might miss 'self [' wish re were available
newstring = string.replace(newstring,'self[', newself + '[')
newbodylist.append(string.rstrip(newstring))
  body = string.join(newbodylist,'\n')
# uncomment to see the raw data
#  print 'params = "%s"' % params
#  print 'body is:\n"%s"' % body
  
#rename the old and create the new.  don't do more than once.
  if method_id [-len(oldscriptsuffix):]  oldscriptsuffix:
container.manage_renameObject(method_id,method_id+oldscriptsuffix)
   
container.manage_addProduct['PythonScripts'].manage_addPythonScript(method_id)
newscript = container[method_id]
newscript.ZPythonScript_setTitle(title)
newscript.ZPythonScript_edit(params, body)
print 'converted: \t%s' % method_id

if len(printed)  9:
  print "No methods to convert"
return printed



Thanks for trying it.  Let me know any other bugs, and I may eventually
publish a howto.

-- Jim

 
 Jim,
 
 Thanks for the script.  I plan to give it a try.


___
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] PythonScripts documentation

2001-01-26 Thread Jim Washington

The new online help in 2.3 may have some answers to your questions.  Do
you have that?
It's in Zope Help-API Reference-PythonScript

-- Jim Washington

Gerald Gutierrez wrote:
 
 Where is the latest documentation for PythonScripts located? The closest I
 found is
 
 http://www.zope.org/Members/4am/PythonMethod
 
 but it is dated and contains minimal information.
 
 I'm specifically interested in what I can do with them and what I cannot do
 with them.
 
 Thanks.

___
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] ZClass Adding Magic Needed

2001-01-17 Thread Jim Washington

Hi, Geoff

Your situation looks like application logic confusion enhanced by the
weirdness of DTML.

Use a Python Script/Method to do the background heavy lifting. If you
are using with, let  and REQUEST.set() to access your items, it can
be done much more simply and understandably in a Python Script/Method.  

-- Jim Washington

"Geoffrey L. Wright" wrote:
 
 So:
 
 I have a odd little problem that I can't seem to solve.  I have two
 zclasses.  We'll call them zclass1 and zclass2.  zclass2 lives inside
 of zclass1.  zclass1 has the following two properties:  id and
 displayOrder.  zclass2 has the four properties: id, displayOrder,
 alignment and content.  In both cases the id is an automaticly
 generated unique number based on ZopeTime.
 
 My problem is that I need to make a public add method that generates a
 new instance of zclass1 with a new instance of zclass2 inside of it.
 I also need to be able to control set the displayOrder of zclass1, and
 the alignment and content of zclass2 from the same form.  The
 displayOrder of zclass2 will be static for the time being, but I'll
 ultimately need to control that as well.
 
 I hacked the default add method of zclass1 so that it generates a new
 instance of zclass2 each time, and using the Job Board HOWTO I managed
 to make a public add method.  So far so good.  But now I can't for the
 life of me figure out how to pass some form variables to one object
 and some to the other, especially while they have some identically named
 properties.
 
 Any hints on this one?

___
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] ZClasses meet PythonScripts, sample request

2001-01-15 Thread Jim Washington

Hi, Tim

You do not need to mess with the Python Script bindings.  It looks like
you are trying to get URL:

www.isd197.k12.mn.us/hr/jobs/postings/1234/editJobAction(REQUEST)

Which of course does not exist.  I would change your form action="..
line to 

form action="editJobAction" method="post"

assuming the DTML Method that has the form is called editJobAction. 
Don't worry about passing REQUEST there; Zope takes care of that.

-- Jim Washington

Timothy Wilson wrote:
 
 This seems to almost work. :-)
 
 On Sun, 14 Jan 2001, Jim Washington wrote:
 
  !dtml-var standard_html_header
 
  !dtml-if "REQUEST.form.has_key('editCD')"
  !  dtml-call "manage_changeCDProperties(REQUEST)"
  !  pfont color="red"Your changes have been saved/font/p
  !/dtml-if
 
  !form action="replace_this_with_id_of_this_method"
   table border="0"
 
   trthTitle/th
tdinput type="text" name="title" value="dtml-var title"/td
   /tr
 
   trthArtist/th
 tdinput type="text" name="artist" value="dtml-var artist"/td
   /tr
 
   trtd
  ! input type="submit" name="editCD" value=" Submit Edits "
   /td/tr
   /table
   /form
  !dtml-var standard_html_footer
 
 That's quite clever. I wouldn't have thought of doing it that way.
 
 After translating the CD example to my own ZClass, I get the following error
 after hitting "Submit Edits" on the edit form:
 
 h2Zope Error/h2
 pZope has encountered an error while publishing this resource.
   /p
 pstrongResource not found/strong/p
 Sorry, the requested Zope resource does not exist.pCheck the URL and try
 again.p
 !--
 http://www.isd197.k12.mn.us/hr/jobs/postings/1234/editJobAction%28REQUEST%29
 --
 
 and the traceback:
 
 Traceback (innermost last):
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in
 publish_module
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in
 publish
   File /var/lib/zope/2.3.0a2/lib/python/Zope/__init__.py, line 221, in
 zpublisher_exception_hook
 (Object: Traversable)
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 162, in
 publish
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/BaseRequest.py, line 369,
 in traverse
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/HTTPResponse.py, line
 528, in notFoundError
 NotFound: (see above)
 
 It looks like REQUEST isn't getting passed correctly. I've got REQUEST
 listed as a parameter for my PythonScript. I don't need to mess with
 bindings do I?

___
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] ZClasses meet PythonScripts, sample request

2001-01-15 Thread Jim Washington

Hi, Tim

I have it.
The Python Script I sent you:

container.propertysheets['job_info'].manage_changeProperties(REQUEST)

needs to be rewritten:

container.propertysheets.job_info.manage_changeProperties(REQUEST)

Perhaps someone could explain why the first does not work.

One point about your form:

You have id as a form variable.  You will be disappointed by its
behavior.

Regards,

-- Jim Washington

Timothy Wilson wrote:
 
 Jim (or anyone else who's feeling charitable this morning),
 
 Thanks for all your help. I really appreciate it. I wonder if you'd have
 time to look one more time at the two methods I've got that aren't
 working. I've included the actual code for my job posting product. Perhaps
 someone will find it instructive. I have a feeling that the remaining
 problem is not directly related to the processing of the form by the
 PythonScript. I also included the traceback at the end of this message.
 
 Here are the two methods. I have a table that displays the currently
 available jobs and displays two little icons which call the edit or delete
 methods on the corresponding instance of the 'Job Posting' class. The edit
 icon links to the 'editJobForm' method which in turn calls the
 'editFormAction' method that actually processing the change.
 
 --
 editJobForm
 -
 
 dtml-var standard_html_header
 
 h2Edit a Job Board Entry/h2
 pThis form allows you to make changes to current postings on the online
 job board. You don't needed to fill in every
 field on the form. Click on the "Submit Edits" button at the bottom of the
 screen to save your changes to the database./p
 
 dtml-if "REQUEST.form.has_key('editJob')"
 dtml-call "editFormAction(REQUEST)"
 pfont color="red"Your changes have been saved/font/p
 /dtml-if
 
 form action="editJobForm"
 table border="0"
 
 trthNotes/th
 tdtextarea name="notes:text" rows="10" cols="60" wrap="virtual"dtml-var
 notes/textarea/td
 /tr
 trthJob ID/th
 tdinput type="text" name="id" size="20" value="dtml-var id"/td
 /tr
 trthOrganization/th
 tdinput type="text" name="organization" size="60" value="dtml-var
 org_name"/td
 /tr
 trthPosition/th
 tdinput type="text" name="position" size="60" value="dtml-var
 name"/td
 /tr
 trthDescription/th
 tdtextarea
 name="description:text" rows="10" cols="60" wrap="virtual"dtml-var
 description/textarea/td
 /tr
 trthPay Offered/th
 tdinput type="text" name="pay" size="60" value="dtml-var pay"/td
 /tr
 trthLine of Authority/th
 tdinput type="text" name="loa" size="60" value="dtml-var loa"/td
 /tr
 trthFunction/th
 tdtextarea
 name="function:text" rows="4" cols="60" wrap="virtual"dtml-var
 function/textarea/td
 /tr
 trthQualifications/th
 tdtextarea
 name="qualifications:text" rows="8" cols="60" wrap="virtual"dtml-var
 qualifications/textarea/td
 /tr
 tr
 td colspan=2
 pTo create a bullet list of "duties," type each one in the box below and
 press the "ENTER" key
 between each item in the list./p
 /td
 /tr
 trthDuties/th
 dtml-if duties
 tdtextarea name="duties:list" rows="10" cols="60" wrap="virtual"dtml-in
 dutiesdtml-let item=sequence-itemdtml-if item
 dtml-var item
 /dtml-if/dtml-let/dtml-in/textarea/td
 dtml-else
 tdtextarea
 name="duties:list" rows="10" cols="60" wrap="virtual"/textarea/td
 /dtml-if
 /tr
 trthOffer Expires/th
 tdinput type="text" name="expires" size="20" value="dtml-var
 offer_expires fmt="%m/%d/%Y""/td
 /tr
 tr
 td colspan=2pEnter the date that the job was officially posted./p/td
 /tr
 trthPosted Date/th
 tdinput type="text" name="posted" size="20" value="dtml-var date_posted
 fmt="%m/%d/%Y""/td
 /tr
 tr
 tdnbsp;/td
 td
 input type="submit" name="editJob" value=" Submit Edits "
 /form
 form action="admin_html"
 input type="submit" value=" Cancel "
 /form
 /td
 /tr
 /table
 
 dtml-var standard_html_footer
 
 -
 editFormAction (with REQUEST as a parameter)
 -
 
 container.propertysheets['job_info'].manage_changeProperties(REQUEST)
 
 The error I get is:
 
  Error Type: TypeError
 Error Value: sequence index must be integer
 
 Traceback:
 
 Traceback (innermost last):
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in
 publish_module
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in
 publish
   File /var/lib/zope/2.3.0a2/li

Re: [Zope] ZClasses meet PythonScripts, sample request

2001-01-15 Thread Jim Washington

Hi, Tim

What is the name of the propertysheet in your ZClass that these values
are on?  Is it 'job_info'?

Where is the editFormAction Python Script? It should be in your ZClass's
/methods.  If you are instead acquiring it from a Folder somewhere, you
will need to use 'context' instead of 'container' inside the Python
Script.

-- Jim Washington


Timothy Wilson wrote:
 
 On Mon, 15 Jan 2001, Jim Washington wrote:
 
  I have it.
  The Python Script I sent you:
 
  container.propertysheets['job_info'].manage_changeProperties(REQUEST)
 
  needs to be rewritten:
 
  container.propertysheets.job_info.manage_changeProperties(REQUEST)
 
 Hey Jim,
 
 I'm getting closer. Now I get the following error and traceback:
 
  Error Type: AttributeError
 Error Value: job_info
 
 Traceback (innermost last):
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in
 publish_module
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in
 publish
   File /var/lib/zope/2.3.0a2/lib/python/Zope/__init__.py, line 221, in
 zpublisher_exception_hook
 (Object: Traversable)
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 171, in
 publish
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/mapply.py, line 160, in
 mapply
 (Object: editJobForm)
   File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 112, in
 call_object
 (Object: editJobForm)
   File /var/lib/zope/2.3.0a2/lib/python/OFS/DTMLMethod.py, line 189, in
 __call__
 (Object: editJobForm)
   File /var/lib/zope/2.3.0a2/lib/python/DocumentTemplate/DT_String.py, line
 538, in __call__
 (Object: editJobForm)
   File /var/lib/zope/2.3.0a2/lib/python/DocumentTemplate/DT_Util.py, line
 336, in eval
 (Object: editFormAction(REQUEST))
 (Info: REQUEST)
   File lt;stringgt;, line 0, in ?
   File /var/lib/zope/2.3.0a2/lib/python/Shared/DC/Scripts/Bindings.py, line
 325, in __call__
 (Object: editFormAction)
   File /var/lib/zope/2.3.0a2/lib/python/Shared/DC/Scripts/Bindings.py, line
 354, in _bindAndExec
 (Object: editFormAction)
   File
 /var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/PythonScript.py,
 line 321, in _exec
 (Object: editFormAction)
 (Info: ({'script': lt;PythonScript instance at 873fbd8gt;,
 'context': lt;JobPosting instance at 86b7dc0gt;, 'container': lt;Folder
 instance at 87225f0gt;, 'traverse_subpath': []},
 (lt;h3gt;formlt;/h3gt;lt;tablegt;lt;tr
 valign=quot;topquot; 
align=quot;leftquot;gt;lt;thgt;postedlt;/thgt;lt;tdgt;'01/15/2001'lt;/tdgt;lt;/trgt;lt;tr
 valign=quot;topquot; 
align=quot;leftquot;gt;lt;thgt;dutieslt;/thgt;lt;tdgt;['asdfasdf\015\012']lt;/tdgt;lt;/trgt;lt;tr
 valign=quot;topquot; 
align=quot;leftquot;gt;lt;thgt;positionlt;/thgt;lt;tdgt;'asdfadsfasd'lt;/tdgt;lt;/trgt;lt;tr
 
 -- again snipping the rest of REQUEST --
 
   File Python Script, line 2, in editFormAction
   File /var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/Guarded.py,
 line 272, in __getattr__
   File /var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/Guarded.py,
 line 143, in __careful_getattr__
 (Object: Traversable)
 AttributeError: (see above)
 
 Any ideas?

___
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] ZClasses meet PythonScripts, sample request

2001-01-15 Thread Jim Washington

Timothy Wilson wrote:
 
 On Mon, 15 Jan 2001, Jim Washington wrote:
 
  Where is the editFormAction Python Script? It should be in your ZClass's
  /methods.  If you are instead acquiring it from a Folder somewhere, you
  will need to use 'context' instead of 'container' inside the Python
  Script.
 
 I'm not getting any errors now that I've changed the editFormAction to refer
 to 'context'. My guy feeling is that these methods should be methods of the
 ZClass so I'll probably change that, but for now no errors.
 
 Unfortunately, however, the instance isn't getting updated either. After
 hitting submit I get the red "Your changes have been saved" and the edit
 form is visible, but the same old values are there. When I view the instance
 after updating I also see the same of values. Apparently either REQUEST
 doesn't contain the data it's supposed to or the instance isn't being
 properly modified with REQUEST's contents. Any thoughts?

I would put the Python Script in the ZClass's /methods and see what
happens.

-- Jim

___
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] ZClasses meet PythonScripts, sample request

2001-01-14 Thread Jim Washington

Hi, Tim

I am not working through that example, but the below is a start on what
you seem to need. Let me know what you think.

good luck!

-- Jim Washington

***

You probably want the work to be done in the context of an instance of
the class, so assure you have "context" bound to the Python Script on
the "bindings" tab.  It's bound by default.

You might want to name the Script in a Zopish way to distinguish it from
other scripts that may do other things.  I would probably call it
manage_changeCDProperties.

You will want to pass REQUEST to it so you can use it like the Zope
builtins:

containerName.CDInfoName.manage_changeCDProperties(REQUEST)

So, put REQUEST in the parameters list.

(BTW, REQUEST is available as context.REQUEST if you choose not to pass
REQUEST.)

Inside the script, you would use Zope's manage_changeProperties method:

context.propertysheets['cd_info'].manage_changeProperties(REQUEST)
-or-
context.propertysheets.cd_info.manage_changeProperties(REQUEST)

You're done, unless you want to get fancy and process the items
separately.

If you want to get fancy, REQUEST.form['title'], REQUEST.form['artist'],
and REQUEST.form['date_purchased'] are available to you.

For example, if you want to assure title case for title and artist (try
this in DTML first, just to get the scope of how much easier it is in a
Python Script):

import string
dontCapitalize = ['a','in','of', 'for']
localPropertiesDict = {}
for aproperty in ['title','artist']:
  theProperty = string.strip(REQUEST.form[aproperty])
  splitWords = string.split(theProperty)
  newlist = []
  for aWord in splitWords:
if aWord in dontCapitalize and aWord != splitWords[0]:
  newlist.append(string.lower(aWord))
else:
  newlist.append(string.capitalize(aWord))
  newValue = string.join(newlist,' ')
  localPropertiesDict[aproperty] = newValue
context.propertysheets['cd_info'].manage_changeProperties(localPropertiesDict)  





To delete something from the ZODB, pass a list of ids to
manage_delObjects in your container.

To delete them all:

thelist = context.containerName.objectIds('CD_Info')
context.containerName.manage_delObjects(thelist)

Let's say you lent out all your Britney Spears CDs and don't expect to
get them back.  How do you update your collection?

Make a form that allows you to select 'Britney Spears' into a variable
called 'deleteThisArtist'

Make a Python Script that is called by the action for the form.  This
goes into your class for CD collection, whatever you have named it.

import string
#we make this case-insensitive by converting all to uppercase
deleteMe = string.upper(context.REQUEST.form['deleteThisArtist'])
listToDel = []
for CD in context.objectValues('CD_Info'):
  if string.upper(CD.artist) == deleteMe:
listToDel.append(CD.id)  #in Zope-2.3.0+, you should use .getId()
instead of .id
context.manage_delObjects(listToDel)


Timothy Wilson wrote:
 
 Hi everyone,
 
 I'm looking forward to using some PythonScripts as methods of some ZClasses
 because it seems like a much cleaner way to do things. I wonder if one of
 the PythonScript gurus out there would be willing to show an example of two
 presumably common PythonScript/ZClass tasks: processing changes to a
 property sheet using form input and deleting a ZClass instance.
 
 Let's say we've got a ZClass for keeping track of a CD collection. (I recall
 seeing that example in a ZClass How-To.) Let's say the ZClass has a property
 sheet called 'cd_info' with the following properties:
 
 title (string)
 artist (string)
 date_purchased (date)
 
 (for extra credit, add a 'songs' property of type 'lines' :-)
 
 Is that enough info? Anybody want to take a crack at this? (This would
 surely be good info to put at zope.org somewhere.)
 
 -Tim

___
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] ZClasses meet PythonScripts, sample request

2001-01-14 Thread Jim Washington

Hi, Tim

 
  You will want to pass REQUEST to it so you can use it like the Zope
  builtins:
 
  containerName.CDInfoName.manage_changeCDProperties(REQUEST)
 
  So, put REQUEST in the parameters list.
 
 I'm afraid I'm a bit confused here. Is 'CDInfoName' the id of an instance of
 this CD class? If so, what would 'containerName' be?

Yes.  CDInfoName here would be an instance of your CD Class. 
containerName is the name of the container, whether it be a folder or a
folderish ZClass made for handling a collection of CD Class objects.  It
doesn't have to be there in the statement unless something else is
asking the folderish object to ask the CD Class object to change the
properties, which at the moment seems kind of silly.  I must have gotten
off on containers with your second question about deletion. Apologies
for the confusion.
 
 In the particular example I'm thinking about (not a CD collection), I've
 created a form that displays the current properties of the class (a job
 opening for the H.R. deparment in my case), allows the user to modify any of
 the properties in the form, and submit those changes. I suppose for the CD
 example it would something like: (ignoring everything but the form)
 
 form action="manage_changeCDProperties(REQUEST)"
 table border="0"
 
 trthTitle/th
   tdinput type="text" name="title" value="dtml-var title"/td
 /tr
 
 trthArtist/th
   tdinput type="text" name="artist" value="dtml-var artist"/td
 /tr
 
 trtd
 input type="submit" value=" Submit Edits "
 /td/tr
 /table
 /form
 
 I don't think I'm calling the PythonScript correctly. In fact, I suspect I'm
 quite a bit off.

I think it would work, at least as far as updating the properties, but
it would not  return anything. See below my attempt at an alternative.

  Inside the script, you would use Zope's manage_changeProperties method:
 
  context.propertysheets['cd_info'].manage_changeProperties(REQUEST)
  -or-
  context.propertysheets.cd_info.manage_changeProperties(REQUEST)
 
 Following Evan's advice, would this then be:
 
 container.propertysheets['cd_info'].manage_changeProperties(REQUEST)
 
 So that's a one-liner? Hmmm. Cool if true. :-)

Always has been, even in DTML. 
 
 Let's say that I wanted to redirect the user back to the Web page where they
 had begun this process. How would that be accomplished?

There are many ways.  I like to make it all happen at the beginning of
the DTML Method.
Hacking up the form you provided above (lines with ! have been added or
changed):

!dtml-var standard_html_header

!dtml-if "REQUEST.form.has_key('editCD')"
!  dtml-call "manage_changeCDProperties(REQUEST)"
!  pfont color="red"Your changes have been saved/font/p
!/dtml-if

!form action="replace_this_with_id_of_this_method"
 table border="0"
 
 trthTitle/th
  tdinput type="text" name="title" value="dtml-var title"/td
 /tr
 
 trthArtist/th
   tdinput type="text" name="artist" value="dtml-var artist"/td
 /tr
 
 trtd
! input type="submit" name="editCD" value=" Submit Edits "
 /td/tr
 /table
 /form
!dtml-var standard_html_footer

Hoping I have not confused further,

-- Jim Washington

  Timothy Wilson wrote:
  
   Hi everyone,
  
   I'm looking forward to using some PythonScripts as methods of some ZClasses
   because it seems like a much cleaner way to do things. I wonder if one of
   the PythonScript gurus out there would be willing to show an example of two
   presumably common PythonScript/ZClass tasks: processing changes to a
   property sheet using form input and deleting a ZClass instance.
  
   Let's say we've got a ZClass for keeping track of a CD collection. (I recall
   seeing that example in a ZClass How-To.) Let's say the ZClass has a property
   sheet called 'cd_info' with the following properties:
  
   title (string)
   artist (string)
   date_purchased (date)
  
   (for extra credit, add a 'songs' property of type 'lines' :-)
  
   Is that enough info? Anybody want to take a crack at this? (This would
   surely be good info to put at zope.org somewhere.)
  
   -Tim

___
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] get property of type 'list'

2001-01-12 Thread Jim Washington

Hi, Andrei

I think I have it figured out.  I just submitted something similar to
the Collector about an analogous problem I have been having with 'lines'
properties.

When you create your tokens property, you should make its value a
string, like:

'1 2 3'

not a list: [1, 2, 3]

If your data is in a list and you want to use that list as tokens, you
need to join the list into a string first:

mylist = ['1', '2', '3']
fortokens = string.join(mylist,' ')

That's the python, but you can do it in DTML using _.string.join(.  Be
careful to convert your integers to strings first.

What's happening to you is that the string representation of the list,
"[1, 2, 3]" is getting stored verbatim as your tokens property, and
ZPublisher/Converters.py is then splitting it on the spaces when you ask
for it. Which is how you get that weird '[1,' '2,' '3]'.

-- Jim Washington

Andrei Belitski wrote:
 
 Hi!
 I add a list property to a DTML document of type 'tokens' (e.g. '[1, 2,
 3]') wenn i try to retrieve it with _.getitem i get '[1,' '2,' '3]'
 instead of '1' '2' '3'
 How can I get Zope to interpret my property like a list not a string or
 whatever else?
 Thank you in advance!
 
 ___
 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 )

-- 

Jim Washington
Center for Assessment, Evaluation and Educational Programming
Department of Teaching and Learning, Virginia Tech

___
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 to split a string in a python method?

2001-01-05 Thread Jim Washington

Yes. Just use it. string is already in the Python Methods namespace.

EXAMPLE:

Python Method 

Parameter list: self

Python function body:

testsentence = 'I want this sentence to be converted into a list of its
component words.'
thelist = string.split(testsentence)
for aword in thelist:
  print aword
return printed

-- Jim Washington

Juan Carlos Coruña wrote:
 
 Is there any way to split a string in a PythonMethod without passing the
 object _.string as an argument?
 
 I have tried to "import string" but Zope generates an ImportError:
 
 ImportError: __import__ not found
 
 I'm using PythonMethod 0.1.7

___
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] html_quote in python methods?

2001-01-03 Thread Jim Washington

Thanks, Andy, Dieter, Chris, Evan for the discussion

What I ended up doing was making a DTML Method called
htmlquote_newlineToBr that looks like:

dtml-var theitem html_quote newline_to_br

then calling it from a Python Method like so:

hqnl = self.htmlquote_newlineToBr
myitem=self.fixedLoc['varLoc1']['varLoc2']

print 'table'
print 'trtd%s/td/tr' % hqnl(theitem=myitem.property1)
print 'table'

It turned out to be a bit better code than I thought I wanted :)

-- Jim Washington

 - Original Message -
 From: "Jim Washington" [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, January 02, 2001 6:32 AM
 Subject: [Zope] html_quote in python methods?
 
  I am using Python Methods a lot now.
 
  Good:
  no more dtml-with to get to the objects I need. Yay!
  no more worrying about closing blocks. Yay!
 
  OK, when I make a syntax error, there is no help in the traceback.  My
  Python is getting better and better as a result.
 
  To give something back, I have a hint that took me a while to figure
  out:
 
  print 'td width="33%"%s/td' % (self.thevariable)
  will not work.  The first % needs to be escaped like so:
 
  print 'td width="33%%"%s/td' % (self.thevariable)
 
  Now, can I use html_quote in a Python Method?  I am letting people enter
  data for redisplay, and I know some Bozo (TM) will somehow put in
  "table"
  and break the page.
 
  Can I keep this from happening?  html_quote does not seem to be in the
  Python Method namespace.

___
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] html_quote in python methods?

2001-01-02 Thread Jim Washington

I am using Python Methods a lot now.

Good:
no more dtml-with to get to the objects I need. Yay!
no more worrying about closing blocks. Yay!

OK, when I make a syntax error, there is no help in the traceback.  My
Python is getting better and better as a result.

To give something back, I have a hint that took me a while to figure
out:

print 'td width="33%"%s/td' % (self.thevariable)
will not work.  The first % needs to be escaped like so:

print 'td width="33%%"%s/td' % (self.thevariable)

Now, can I use html_quote in a Python Method?  I am letting people enter
data for redisplay, and I know some Bozo (TM) will somehow put in 
"table"
and break the page.

Can I keep this from happening?  html_quote does not seem to be in the
Python Method namespace.

Regards,

-- Jim Washington

___
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] Anonymous user

2000-12-21 Thread Jim Washington

There might be a couple more variables to consider.

If I were trying to get back into my site I would try:

1.  Clearing the browser cache
2.  Using the "superuser" name and password
3.  Going directly to the management pages:  /manage_workspace
(manage_access does security, and manage_UndoForm has the undo stuff if
you just want to undo the last permissions change)
4.  Using a different browser (the "username:password@" convention is
apparently not handled uniformly by the various browsers).  

Cookies should not make too much of a difference, but management screens
do use them for the tree tags and height/width of edit boxes.  You are
still using basic authentication, I presume?

Keep trying.  All is not lost.  One of the above or some combination
ought to work.  

-- Jim Washington


Priya Ramkumar wrote:
 
 Hi Jim
 
 I tried typing the following url but it still logs in as "anonymous user".
 The cookies are also disabled in my browser.
 
 priya
 
 Put the username and password in the url like this:
 
 http://managername:[EMAIL PROTECTED]/manage
 
 -- Jim Washington
 
  Priya Ramkumar wrote:
 
  Hi
 
  Could anyone please help me with this problem?
 
  I changed the default permission for the Anonymous user by adding the
  permission "View Management screens". So the next time I opened the
  site, and wanted to go into the management screen, it took me directly
  to the management screen. But as an Anonymous user, I do not have any
  security permissions and hence unable to change back the permissions.
  The problem is that I want to now login as "manager" and i am unable
  to do so as it does not wait for the username  password to go to the
  management screen. What is the way I could login as manager again 
  change the permission settings?
 

___
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] Anonymous user

2000-12-20 Thread Jim Washington

Put the username and password in the url like this:

http://managername:[EMAIL PROTECTED]/manage 

-- Jim Washington

 Priya Ramkumar wrote:
 
 Hi
 
 Could anyone please help me with this problem?
 
 I changed the default permission for the Anonymous user by adding the
 permission "View Management screens". So the next time I opened the
 site, and wanted to go into the management screen, it took me directly
 to the management screen. But as an Anonymous user, I do not have any
 security permissions and hence unable to change back the permissions.
 The problem is that I want to now login as "manager" and i am unable
 to do so as it does not wait for the username  password to go to the
 management screen. What is the way I could login as manager again 
 change the permission settings?

___
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] mySQL DA on Win32

2000-12-14 Thread Jim Washington

Hi, Lee

I got zope and mysql working together last night on win2k.  I used the
instructions in

http://www.zope.org/Members/philh/mysql

(Thanks, Phil Harris!)

I did have to use the custom dll and pyd mentioned there.

http://www.google.com/search?q=mysql+zope+win32 might have more clues if
this does not meet your needs.  

To answer your next question, 
the connection string is like 'db@host username password'

hth,

-- Jim Washington

Lee Reilly CS1997 wrote:
 
 Hi,
 
 Zope is currently being installed on the Unix machines at my uni but it
 won't be available for a while. However, I have set up a mySQL database
 in the Dept. and installed Zope on a Dept. machine (Windows 95). I can
 only access the database from uni so I must have a database adpater
 setup on this machine.
 
 I have seen the mySQL DA on Zope.org but I understand that it "does not
 support win32 platforms at this time". I need database access ASAP so
 can anyone offer any advice?
 
 Thanks very much,
 
 Lee

___
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] string splitting in dtml

2000-12-06 Thread Jim Washington

Just a thought:

Have you tried using "_.str(thedate)" to convert it into a string?  I am
not using Access, but since Zope can handle the Access date stuff
properly, it may be using something like _.str() internally.  It's what
I would try first.

-- Jim Washington

"Spicklemire, Jerry" wrote:
 
 Mike said:
 
  I tried what you recommended and got the following error:
 
  Error Type: AttributeError
  Error Value: __getslice__
 
  The problem I think is that the variable is drawn from the database as
 type
  date (Microsoft Access 2k) and somehow is cast into a date type.  Is there
 a
  way to re-cast this variable as a string type?
 
 You're right, it's not really a string, even though Zope is smart enough
 to render it into one when inserting it directly into HTML.
 
  I also tried the
 
  dtml-var "_.string.split(start_date, '/')[1]"
 
  solution but got the error:
 
  Error Type: TypeError
  Error Value: argument 1: expected read-only character buffer, instance
 found
 
 Now if only Zope were smart enough to tel us what it "really" is,
 so we could transform it!
 
 It looks like MS Access delivers dates as some proprietary object type.
 
 However, in your query, you may be able to wrap the date field like so:
 
 to_char(dateFieldName)
 
 to convince MS Access to return a formatted string instead.
 Once you can see what the string looks like, the slicing bit
 should work.

___
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] come see new.zope.org

2000-11-27 Thread Jim Washington

For the time being, most of us probably want to put 63.102.49.33 in the
/etc/hosts file (I forget where it is in Win32) so all the links work.
It seems pretty quick from here.  Good show, Ethan!

-- Jim Washington


Chris Gray wrote:
 
 Then try 63.102.49.33.  The new name just hasn't propagated to your
 dnsserver yet.
 
 Chris

___
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] Newbie Question

2000-11-24 Thread Jim Washington

Dany:


These should work:


dtml-in objectIds

dtml-var "_['sequence-item']"

/dtml-in

-or-


dtml-in objectValues

dtml-var sequence-item
 
/dtml-in

-or-

dtml-in objectValues

dtml-var some_attribute_of_the_sequence-item
 
/dtml-in


--Jim Washington

Dany Rioux wrote:
 
 I'm probably just being dumb... :)
 
 PASTE--
 dtml-var standard_html_header
 
 p
 dtml-with News
  dtml-in objectValues
  /dtml-in
 /dtml-with
 /p
 
 dtml-var standard_html_footer
 /PASTE--
 
 This doesn't work. Nothing gets printed.
 
 In the News folder is a DTML method called news999. Should it be a
 DTML document instead for this to work?
 
 I tried the three methods you gave me. objectValues, "objectValues()"
 and "objectValues('[File]')" and even "objectValues('[news999]')" but
 empty everytime.


___
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] ZClasses inheriting property(sheets) : yes/no?

2000-11-10 Thread Jim Washington

Hi, Aaron

Yes.

If your parent ZClass is constructed properly, you should be able to add
the parent class's management tabs by setting a "view". On the "Views"
tab, look in the Method list for
propertysheets/[ParentClassPropertySheetName]/manage.  The properties on
that sheet are accessible just like any of the child class's properties.

-- Jim Washington

Aaron Straup Cope wrote:
 
 Hi,
 
 If I create a ZClass that inherits another ZClass, do I also inherit the
 latter's properties/propertysheet? From what I've read so far, I thought
 the answer was yes but I can't seem to figure out how to *get* at them.
 
 I created a ZClass called "Foo" that inherits a ZClass named "Meta". Meta
 had two properties : author and title but neither appear to be set when
 I create a new Foo object.
 
 I banged out something in plain-old Python (see below) since I was pretty
 sure this was the kind of thing Python was so good for (I am normally a
 Perl weeniesh :-) and everything worked fine.
 
 I've been looking around the docs and the how-to's but nothing seems to
 discuss the idea of inheriting properties (?) across ZClasses. Is it
 possible?
 
 Thanks,
 
 class Meta:
def __init__(self,title,author,timestamp,keywords,body,public,display):
self.title = title
self.author= author
self.timestamp = timestamp
self.keywords  = keywords
self.body  = body
self.display   = display
self.public= public
 
 
 
 from Meta import Meta
 class Library(Meta):
   def
 __init__(self,title,author,timestamp,keywords,body,public,display,foo,bar=""):
 
 Meta.__init__(self,title,author,timestamp,keywords,body,public,display)
   self.foo = foo
   self.bar = bar
 
 
 
 from Meta import Meta
 class LibraryClass(Meta):
   def __init__(self,title,author,timestamp,keywords,body,public,display):
 Meta.__init__(self,title,author,timestamp,keywords,body,public,display)
 
 ***
 
 # from yadda yadda import ...
 lib  = Library("budwork","bud","now",["foo","bar"],"bobdy",1,0,"foopybird")
 libclass = LibraryClass("classwork","bud","now",["foo","bar"],"bobdy",1,0)
 
 print "Class Title is " + lib.title
 print "LibClass Title is " + libclass.title
 
 ___
 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 )

-- 

Jim Washington
Center for Assessment, Evaluation and Educational Programming
Department of Teaching and Learning, Virginia Tech

___
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-dev] Python Product Style - on-the-fly objects to DTML

2000-11-09 Thread Jim Washington

Hi, all

I have a project going that requires the users to fill-out many
different tabular data forms.

So, I thought I would develop yet another table-generator.  The main
class (descended from OFS.SimpleItem) has a reorderable list of
information (MT_ColumnInfo(Persistent)) about the columns (title, name,
type, size, etc.) and another reorderable list of information about the
rows (MT_RowInfo(Persistent)) (title, name), so that the column names
and row names can be put together and I do not have to worry about
getting R*C names right for each table.

Anyway, I do not want to return any of these classes to DTML for
processing.  I want another class, CellInfo, which has the concatenated
row and column names as name, and the type, size, etc. information from
the Column information.  A list of these with the title of the Row would
be a row_data, so what I have to work with in DTML is the
column_headings list and a list of row_data objects containing a list of
CellInfos. All of these can be generated on-the-fly, so should not need
to be descended from a Persistent Class.  Less stuff to change if the
table needs to be modified / reordered.

But:  In my usual trial-and-success blundering about, I find that unless
these objects participate in the security system, I get "the login
window that will not leave".  So, I descend these objects from
OFS.SimpleItem and give them default __ac_permissions__.  Everything
works as expected.  

Looking closer, I see that the thing really working is: 
descent from AccessControl.Role.RoleManager
and 
__allow_access_to_unprotected_subobjects__=1.

So I make these modifications, and everything seems fine. Allowing
access to unprotected subobjects is cool, since these are
non-persistent.

Now for the question:  What happened when I created un-attached
Persistent descendents on-the-fly while testing earlier?  I presume they
garbage-collected away when I was done with them. Is this correct?  I
have a nagging worry about ghost objects and the types of programming
errors that might create them.

-- 

Jim Washington

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




Re: [Zope] QSurvey design

2000-11-01 Thread Jim Washington

Hi, Stephan

QPages draw themselves.  The code is QPageClass:index_html, so replacing
the header information in that method with standard_html_header should
work.  You may want to include the css stuff in your header for question
formatting (needs to be in head, and that is why I broke tradition and
hard-wired the header). Standard_html_footer is still there, so that
should already work.

-- Jim Washington

Stephan Goeldi wrote:
 
 How can I change the HTML design of QSurvey 0.25?
 I want it to use my standard_html_header and footer.


___
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 to type check OR better list selector ways

2000-10-20 Thread Jim Washington

Hi, Robert

BTW, this is a FAQ, but:

use the :list extension in your html.

e.g.,

select multiple name="dtml-var form_save_name:list"
dtml-in thelistitems
  option value="dtml-var sequence-item"dtml-var
sequence-item/option
/dtml-in
/select

Works for checkboxes, too!

-- Jim Washington

Robert Joseph Roos wrote:
 
 dtml-expr="_.type(some_variable_of_unknown_type)"
 
 causes a name error, while other python builtins
 like _.string(some_int) work fine.  What gives?
 Is there some other "zopist" way to type-check?
 
 More generally, is there a better way to deal with the annoying
 fact that multiple selectors return a list UNLESS there are
 =1 items selected, in which case they return a single item or None?
 
 (rather than a list with only one member, in the case of 1 object
 selected, or an empty list, in the case of none,
 which would SEEM to be the consistant way to do things,
 since dtml-in wouldn't choke.)

___
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 to include Flash/SWF objects in Zope website?

2000-10-16 Thread Jim Washington

N.B. You probably should add your Flash/SWF objects as "File" objects. 
DTML Method/Document objects can do amusing things with binary data, 
which is why there are "File" objects.

-- Jim Washington

J. Atwood wrote:

 You could just upload them into Zope and point to them.
 
 http://www.gotschool.com (see flash demos).
 
 It uploads as a "application/octet-stream"
 
 I am sure you are talking about much more interaction.
 
 J
 



___
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] Re: [Zope-dev] build Zope on linux

2000-10-09 Thread Jim Washington

Hi, Kent Sin

dpkg -S tells you what package contains a file:

jwashin@vpave5:/$ dpkg -S mymath.h
python-dev: /usr/include/python1.5/mymath.h

So, it would appear the python-dev package is the one you need.

-- Jim Washington


Sin Hang Kin wrote:
 
 When building current zope cvs, cPickle.c want the mymath.h. Where can I get
 mymath? What devel package I should install for a debian system?
 
 Rgs,
 
 Kent Sin
 -
 kentsin.weblogs.com
 kentsin.imeme.net

___
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] Base ZClass propertysheet management

2000-10-06 Thread Jim Washington

Hi, Seb

Go to the "Views" tab of the ProductItem ZClass.  You should be able to
add another tab referring to propertysheets/Picture/manage.  This has
worked for me in a similar situation.

-- Jim Washington

Seb Bacon wrote:
 
 Thanks,
 
 I'll rephrase it using my real life problem:
 
 I have a Picture class, which comprises image, title, description, etc.
 I also have a ProductItem class, which subclasses Picture to include a
 price, etc.
 
 So finally I have got a ProductItem class, which has a title, image, price,
 ...
 
 I can access properties inherited from the Picture no problem.  The problem
 is that the default management screen for editing the properties of
 ProductItem, propertysheets/Details/manage, only provides a means of editing
 the unique properties of ProductItem.  Is there a means of managing all the
 properties of a ZClass, including those of its parent class?  Or do I have
 to code my own management screen to do this?  And if so, what is the correct
 way of refering to these properties in DTML?

___
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] help! dtml-if question

2000-10-04 Thread Jim Washington

Hi, Anthony

how about:

dtml-if "_.len(objectValues(['Blurb']))  0"

Your _.has_key() (I think you meant _.hasattr()) statement was looking 
for something named "Blurb", not a thing of type"Blurb", so of course it 
failed.

The objectValues(['atype']) statement returns a list of the things of 
the type,  so checking for a non-zero length of the list will do what 
you need.

-- Jim Washington

Dr. Anthony Monta wrote:

 Hi,
 
 I've tried to find a solution myself but now am stuck.  I created a 
 little "Blurb" product for a university department website so that 
 faculty members can announce recent publications on the department's 
 homepage.  They create these ZClass instances in their own folders, 
 and a DTML method in the top-level folder grabs and displays them at 
 random.  (I want to avoid using ZCatalog for the time being.)  What 
 the method does is randomly choose a faculty folder, and then randomly 
 choose a Blurb instance within that folder.  Here's the hack I came up 
 with:
 
 dtml-with Dept
  dtml-with Fac
   dtml-with Sites
dtml-with "_.whrandom.choice(objectValues(['Folder']))"
 dtml-with "_.whrandom.choice(objectValues(['Blurb']))"
  dtml-var index_html
 
 (end tags omitted)
 
 The problem is that this method will produce an Index Error when it 
 comes across a folder that doesn't contain an instance of "Blurb" 
 class.  So I need to make the selection of a folder conditional on 
 Zope's finding a Blurb in that folder.  Here's what I tried after 
 reading up:
 
 dtml-with Dept
  dtml-with Fac
   dtml-with Sites
dtml-with "_.whrandom.choice(objectValues(['Folder']))"
 dtml-if "_.has_key('Blurb')"
  dtml-with "_.whrandom.choice(objectValues(['Blurb']))"
   dtml-var index_html
/dtml-with
 dtml-else
  Some default Blurb would appear.
 
 This method fails.  Can someone help?
 


___
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] List

2000-10-03 Thread Jim Washington

Tom Deprez wrote:
 
 Hi,
 
 I'm storing a selection of a user to a database as string. This selection
 is a multiple selection from a select box and is outputted as a list.
 Now I want to iterate over this list (after retrieving it from the
 database), but how can I do this? How can I tell Zope that the string is
 actually a list? How can I typecast in Zope?

Use a python or external method to make a list from your string.  I am
supposing you are storing a string representation of the list that looks
like:

"['fred', 'bob', 'mary']"

Get rid of any punctuation you do not want with (e.g.) 

theString = string.replace(theString, '[', ' ')

(Yes, there are more efficient ways to do this!)

Then, once you have a space-delimited list of items, you may use

theList = string.split(theString)

which will make a list of the words in the string.  Return theList.

-- Jim Washington

___
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] QSurvey 0.23 and Zope 2.2.1b

2000-08-22 Thread Jim Washington

Hi, Alexander

I have not worked with 2.2.1b yet and have not seen this.

But it sounds like the import is expecting things to be in a different
order than the export, which does not help much for a solution. Thus I
agree with the error message: 

(Waaa).

If it wasn't for the b I would possibly:

1.  Upgrade a test zope to 2.2.1b that has the QSurvey working
2.  Export that Product
3.  See if the new export works with the new 2.2.1b ZODB in a different
install.



I would also submit a bug report to the Collector.

-- Jim Washington


 
 Just installed Z2.2.1b, successfully imported some products but when
 trying to import QSurvey 0.23 got the message:
 
 Zope Error
 Zope has encountered an error while publishing this resource.
 
 Error Type: Permission mapping error
 Error Value: Attempted to map a permission to a permission, Add
 QSurveyResultsItems, that is not valid. This should never happen. (Waaa).
 
 Any suggestions?


___
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] Changing my session identity

2000-07-20 Thread Jim Washington

How does one become Anonymous User without stopping/restarting the
browser? Is there a special username/password for that?

-- Jim Washington

Chris McDonough wrote:
 
 Oops... sorry...
 dtml-raise Unauthorized
 Unauthorized.
 /dtml-raise
 
 Shortcuts on the brain.  :-)
 
  -Original Message-
  From: Chris McDonough [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, July 19, 2000 11:43 AM
  To: 'Andreas Rippel'; [EMAIL PROTECTED]
  Subject: RE: [Zope] Changing my session identity
 
 
  In dtml:
 
  raise Unauthorized
  You are unauthorized.
  /raise
 
  If you enter a new valid username/password combo in, you'll
  be validated
  and your identity will be changed.
 
  If you cancel or enter an invalid username/password combo,
  you'll still
  be logged in as whomever you started with.

___
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] Problem with _[xyz]

2000-07-07 Thread Jim Washington

Hi, Christian

Christian Zagrodnick wrote:
 
 Hi all,
 
 shouldn't dtml-var xyz and dtml-var "_['xyz']" return the same result?

if xyz is a simple variable, yes.
 
 Well - I don't know why but only the 1st is working.
 (top.German.ActualPages is a folder; tThisIs... is a dtml-method)
 
 1:
 dtml-with "top.German.ActualPages"
 dtml-var tThisIsTheXYZDocument
 /dtml-with
 
 2:
 dtml-with "_['top.German.ActualPages']"
 dtml-var tThisIsTheXYZDocument
 /dtml-with

I may be wrong on this, but if the dots indicate subobjects, you may
want to do this

as Python sequence syntax: "_['top']['German']['ActualPages']"

or as "_['top'][aLanguage]['ActualPages']" assuming aLanguage is a
variable which may be e.g., 'German'

I hope this is a helpful hint.

-- Jim Washington
 
 Of course I want to replace the 'top.German.ActualPages' with a variable...
 but since it doesn't work with a hardcoded string it'll not work with a
 variable.
 
 Any hint?
 
 Thanks

___
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] Newbie Question (dropdown menu)

2000-06-21 Thread Jim Washington

Hi, Joel

untested

Just displaying the list in a select:

select name="whatever"
dtml-in ZSQLMethodthatgetsthelist
option value="dtml-var theFieldname"dtml-var theFieldname/option
/dtml-in
/select

If "whatever" already has a value and you want that selected:

select name="whatever"
dtml-in ZSQLMethodthatgetsthelist
option value="dtml-var theFieldname"
dtml-if "whatever == theFieldname" selected /dtml-if
dtml-var theFieldname/option
/dtml-in
/select

/untested

the /option tags are apparently optional.

hth

-- Jim Washington

joel grimes wrote:
 
 I'm trying to fill a combo-box (pardon the vb-centric lingo - I don't know
 what the things are called - it's a select...option... thing) with items
 selected from a table.  I haven't a clue how to do this.  I've got the ODBC
 Connection and SQL Method working, but how do I iterate through the query
 results to fill a drop-down?
 
 Thanks
 
 Joel Grimes

___
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-06-21 Thread Jim Washington

from the DTML reference page 41, regarding dtml-in:

the default setting for the orphan attribute is 3.

So you might try:

dtml-in ranked_stories size=3 orphan=0 

-- Jim Washington

Tom Scheidt wrote:
 
 Hi my problem is that Im setting my batch size to 3, yet I keep getting
 5 items. As a matter of fact, sometimes I get 4 when asking for 2 and so on.
 Here's what Im using:
 

[code snipped]

 
 Thanks in advance.
 Tom Scheidt   |   www.falsemirror.com   |   [EMAIL PROTECTED]

___
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] Comfirming Hotfix is installed.

2000-06-16 Thread Jim Washington

Look in /Control_Panel/Products for the Hotfix_xx Product.

-- Jim Washington

Ian Thomas wrote:
 
 Is there any way to confirm that the hotfix has been installed?
 
 I extracted the files and restarted Zope but it would be nice if there was
 a way to confirm that it is installed.
 
 ___
 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 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] Importing data

2000-06-15 Thread Jim Washington

Please, no HTML posts.  I crashed Netscape Mail twice trying to reply. 
Thanks.

But to answer, exporting and importing works just fine if you want to
copy parts of an existing zope site.  It even works recursively, so if
you want to export an entire folder of stuff (or Squishdot site) with
subfolders, properties, etc., just go to its enclosing folder's
"Import/Export" management tab, and follow the directions for
exporting.  This will create a .zexp file.

To import into the new Data.fs file, put the .zexp file you have created
into your [where zope is installed]/import folder on your hard drive. 
Then open the new site's management interface for zope and go to the
same Import/Export tab and use the Import part.

If you have 2 Data.fs files and only 1 zope, you can switch back and
forth between them (stopping and restarting Zope in between so terrible
things do not happen) by moving one and then the other into the
appropriate var directory to do exporting, or importing as you want. 
Copies of the original files will come in handy if you confuse easily
like me.

-- Jim Washington

Well, I meant that I have some products w/ data setup in the new .fs.  If I copy the 
old over then I loose what I am currently working on.

   - Original Message - 
   From: J. Michael Mc Kay 
   To: [EMAIL PROTECTED] 
   Sent: Thursday, June 15, 2000 12:26 PM
   Subject: [Zope] Importing data

   I have a Data.fs file from a previous instal of Zope.  How can import parts of 
that data base to a current data.fs?

   I have a product setup in the old .fs that I want to use in the newlike a 
squishdot for instance.

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