Re: [Zope] subfolder wrong absolute_url

2000-05-18 Thread Steve Alexander

Ulrich Wisser wrote:
 
 
 The path is used by the browser, not Zope. IE and Netscape
 will store your login/password to send it with every GET request
 which is in the path, e.g.:
 
 authenticate on /  - path is / - all request will be with auth info
 authenticate on /sub   - path is / - see above
 authentivate on /sub/  - path is /sub/ - only request with /sub/ will be
with auth info
 
 But all this is done by the browser.
 
 I believe the folder object should give a trailing "/" as absolute url.

In that case, you're right :-)

However, any Zope object can potentially have sub-objects or attributes.
As far as a browser is concerned, the any zope object can look like a
folder at some point. Add acquisition into the mix, and you can make a
URL to a valid object have other stuff on the end to an arbitrary
length.

Therefore, your suggestion above should apply to just about all URLs
Zope receives. If Zope receives a request for "/spam/spam/foo" it should
always issue a redirect (or whatever code it should be) to
"/spam/spam/foo/" -- regardless of whether foo is of Folder type,
ObjectManager type or DTML method type, or whatever.

Are there any downsides to having this behaviour for all objects/all
URLs?

Or perhaps there could be some kind of per-path switch inside Zope that
turns the redirect behaviour on or off.

--
Steve Alexander
Software Engineer
Cat-Box limited

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




Re: [Zope] Zope/Apache Image Catalog

2000-05-20 Thread Steve Alexander

Tom Scheidt wrote:
 
 Hi
 
 I want to be able to upload images into a folder on Apache using
 a form page in Zope, and at the same time have the ids cataloged
 with keywords into a ZCatalog. Basically, to be able to search on
 keywords and have the related images displayed on a page.
 
 Does anyone have any recommendations, or know of any
 examples of this? Thanks in advance.

What follows is a terse answer explaining how I'd go about it, but
giving no information about how to accomplish each of the steps. sorry I
can't offer any more right now. Hope it helps.



Create a ZClass that represents the metadata of your image objects --
that is,

  Path to the image on Apache
  Keywords

Each time someone enters an image, save the image via LocalFS to a
filesystem folder accessible from Apache, and create an instance of your
metadata ZClass.

Your metadata ZClass should derive fom CatalogAware.

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] detect root folder

2000-05-20 Thread Steve Alexander

Sin Hang Kin wrote:
 
 Hi,
 
 Is it possible to detect the top folder in dtml?
 
 I means I would like to prevent squishdot to show the ../ when it is already
 in the top level.

dtml-if "_.len(PARENTS) == 1"
  We're at the root folder
dtml-else
  You can go up from here
/dtml-if


--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] Advocacy FAQ?

2000-05-23 Thread Steve Alexander

srl wrote:
 
 So, I was hanging out on IRC last night, and mentioned Zope to
 someone who's fairly active in the Python community. I ended up
 receiving a rant about how "bloated" and slow Zope is...

"Slow" is a relative term. Zope will always be slower than hard-coding
an application in Python.

For the kind of applications I have, I'm happy to throw a bit more
hardware at a server, if I get an improvement in reuse,
understandability or maintainability.

Maintenance accounts for much more than half the cost of most projects.

--
Steve Alexander
Software Engineer
Cat-Box limited

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




Re: [Zope] calling an Python builtin function

2000-05-23 Thread Steve Alexander

Felipe Alvarez Harnecker wrote:
 
 Hi Zopistas,
 
 it's a pain looking to variables defined in a form such as checkboxes
 that can be a string if one is selected or a sequence if many are.
 
 to solve this problem i'd like to do something like:
 
 dtml-let checkbox="list(checkbox)"
 ...
 ...
 /dtml-let
 
 That is, calling the list function of Python on checkbox.
 
 But that doesn't work, neither dtml-let checkbox="_.list(checkbox)"
 
 Beside of this, is there a way to test if foo is a string or a
 sequence or whatever ??

Sounds like you might want this

  http://www.zope.org/Members/Zen/howto/FormVariableTypes

Coerce your form fields into the types you require by using magic
incantations of the form variablename:type.

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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: case sensitive folder problem

2000-05-24 Thread Steve Alexander

Alexander N Gould wrote:
 
 How can I make a folder on my site case - insensitive in regards to access
 from URLs.  If someone types http://mysite.com/bigfolder/ into their
 browser, I want it to take them to the Bigfolder, but right now, it
 produces a missing object error.  Any hints?  Sorry if this is a silly
 question - I'm just getting started here.
 
 I use zope with pcgi on Apache.

You can solve this using a DTML method called bigfolder:

dtml-call "RESPONSE.setBase(Bigfolder.absolute_url())"
dtml-with Bigfolder
  dtml-var index_html
/dtml-with


However, this won't help you if you want things to be totally
case-insensitive, like having "bIgFolDer" direct to "Bigfolder" for
example.

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] M$soft

2000-05-25 Thread Steve Alexander

Henny van der Linde wrote:
 
 Basically: if all you want to do is just serve some data from simple tables
 with not more then 5 concurrent users you can pull it of with Access etc.

There are well known problems with data corruption caused by multiple
concurrent access to Microsoft Access.

Here's a reference that dropped from Google when I asked "corruption
concurrent microsoft access database"

  http://dgl.com/dglinfo/1998/dg980825.html (half way down page)

I wouldn't use Access with Zope.

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] Passing all POST variables?

2000-05-26 Thread Steve Alexander

Stuart 'Zen' Bishop wrote:
 
 I almost got around to doing this for GUF. It would involve interrogating
 REQUEST.form, and generating a load of hidden controls.
 
 One problem to be solved is that in some cases Zope will have messed
 with your form data before your code sees it (The name="myname:int"
 notation). It would be possible to handle some of these cases using
 an external method to interrogate the data type and generate the correct
 input type=hidden name="myname:int" code, but I can't see how to
 handle :record or :method etc.

Here's a very silly idea:

Could you pickle and Base64 encode the data you want to pass, and then
shove it in a single hidden control?

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] PROPOSAL: Online chat with Jim and Paul

2000-05-28 Thread Steve Alexander

Paul Everitt wrote:
  
 I propose an IRC chat on Wednesday with Jim Fulton and me.  

Try and pick a time that's not *too* late at night for us Europeans.

--
Steve Alexander
Software Engineer
Cat-Box limited

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




Re: [Zope] Zope Email (syndication)

2000-05-31 Thread Steve Alexander

"Karl G. Ulbrich" wrote:
 
   Yup, this sounds like mail-in content to me, which is what I'm after :-)
 
 If the goal is mail-in content, I'm not sure I understand IMAP to be
 anything approaching what you want:  IMAP doesn't ACCEPT messages,
 at least not any of the IMAP servers I've seen, it serves messages
 up to clients (one of which could be Zope, like WorldPilot does).

IMAP servers don't accept messages for forwarding or delivery. However,
they do accept messages to be placed in their folders. For example, I
use Netscape and Cyrus IMAP. When I send out an email, Netscape places a
copy of the email in a Cyrus IMAP "sent mail" folder.

You could expose the ZODB object tree as IMAP folders and messages. Then
you would be able to view objects, perhaps with each view of an object
represented as part of a multi-part MIME message. You'd be able to
upload new objects by writing them as emails.

I reckon this is quite feasible, and possibly even useful :-)

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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 book from Beehive.de

2000-06-03 Thread Steve Alexander

FR Chalaoux wrote:
 
 Hi,
 
 Before I insert 25DM in Beehive for the ZClass book, I would like to
 have your point of view on this book !

One of my colleagues has just finished working through the tutorial.

I asked her a few questions about it. Here are her answers.



 1: Is the tutorial you've been doing worth 10 quid?

Definitely (though that's not saying it couldn't be improved)


 2: What skill level is it aimed at?

Ostensibly beginner, but to really understand it I needed to have a
general understanding of Zope (from doing the Zope tutorial), Python (at
absolute beginner level), a bit of DTML (from reading the DTML
reference, and being talked to by a clever person) and HTML. It was
probably also helpful that I had a vague background knowledge of OO
principles, databases and stuff.

So, aimed at ZClass beginners with relevant background knowledge.


 3: What did you get out of it?

I feel competent to set up a simple interactive application using
ZClasses now.
Security and linking to external databases were outside the scope of the
tutorial.
 

 4: Other general comments?

It told a good story, presented coherent examples, built up a little
self-contained system, and generally speaking, taught it well.

However, there  were a few iffy bits: some of the HTML in the examples
was technically incorrect, and the DTML coding style was sometimes
over-verbose and not properly explained. 

My biggest problem using the tutorial was caused by my not realising
that ZClass meta-types are case-sensitive. This was not stressed in the
tutorial - take care!

Overall I'd rate it 8/10, losing points chiefly for poor coding style
and a few inadequate explanations. As a whole, it's been very useful
(and saved the CTO a lot of time talking me through things).



We'll be sending our detailed comments on the explanations, and HTML and
DTML problems, back to Beehive. 


You may also wish to look at the ZCatalog tutorial, the Job-Board
how-to, and the Creating a catalog-aware ZClass how-to.

  http://www.zope.org/Documentation/How-To/ZCatalogTutorial
  http://www.zope.org/Members/mukhsein/job_board_howto
  http://www.zope.org/Members/AlexR/CatalogAware

Also, see what you can find on the Zope Documentation Project pages:

  http://zdp.zope.org/

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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: passing variables

2000-06-18 Thread Steve Alexander

josh on wrote:
 
 Is there a way to pass variables from one page to another using an a href
 but not including them in the url after a ??
 
 sorry, I know this is an html question, but I figured it was pretty zope
 related.

Josh,

This is a "[EMAIL PROTECTED]" question, not a "[EMAIL PROTECTED]" question,
so I've moved the thread to there.


You can do what you want in a couple of ways:

1: Cookies

Can your HTTP clients use Cookies? You can send a cookie on one page and
retrieve it on the next. Look at the "Zope Developer's Guide" and for
information on Cookies and the RESPONSE variable.
Watch out though -- if you pass data in a cookie, and expect to use that
data retrieved later, you could be opening yourself up to a security
risk. A client could change the data in the cookie to mean something
different, and you might never find out.

2: Sessions

Use one of the NNNSession products, such as FSSession or SQLSession.
These use cookies behind the scenes, but present you with a nice
programming interface. Also, your actual data (session variable and so
forth) live on the server. The cookie just tells the server where to
find them. Thus, no part of your data is entrusted to the client.


I'd suggest you look at the FSSession product:

  http://www.zope.org/Members/gaaros/FSSession

Or perhaps HappySession:

  http://www.zope.org/Members/hungjunglu/Products/HappySession

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] OQL

2000-06-24 Thread Steve Alexander


Rogerio Atem de Carvalho [EMAIL PROTECTED] wrote:
 I have a question: Will ZODB have something like OQL?
 The problem in using ZODB is to do simple queries and 
 link different class object instances in queries (SQL 
 join).
 It is hard to do simple things in ZODB like aggregate 
 functions (sum, max ...)
 That's why I use an external RDBMS...

The XPath and XQuery support that ought to be coming along with the new
XML support will handle this, although not with OQL as such. The
functionality will be about equivalent, though.

  http://www.zope.org/Wikis/zope-xml/XPath%20in%20Zope

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: Question (was on zope-ptk)

2000-06-30 Thread Steve Alexander

Hi Jonathan,

I arbitrarily deem this to be a [EMAIL PROTECTED] rather than a
[EMAIL PROTECTED] question, so I'll move it there :-)


Jonathan Desp, who wants to upload a lot of files into Zope, wrote:
 
 someone said me to use load site, but there is a bug with this program.

What is the bug in loadsite that is stopping you from using it?

You have a couple of options here we haven't explored yet:

  1: Fix the bug in loadsite yourself.
  2: Describe the bug in sufficient detail that someone else
 feels moved to spend time fixing it.

 Anyone know another way to upload 900 files in one shot ?

What kind of files are they? What do you want to do with them once
they're in Zope?

Is uploading these files a recurring need you have, or is it a one-off?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: Question (was on zope-ptk)

2000-06-30 Thread Steve Alexander

Jonathan Desp wrote:
 
   Anyone know another way to upload 900 files in one shot ?
 
  What kind of files are they? What do you want to do with them once
  they're in Zope?
 
 they are all in .html, I want to publish it inside www.atomasoft.com, as
 a website.

You should be able to simply FTP these files into Zope. Have you tried
this?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Shutting down Zope

2000-07-02 Thread Steve Alexander

Jonathan,

Jonathan Desp wrote:
 How I can shut down zope without clicking on the shutdown button ?
 because I'm not able to see the page.

You can run the "stop" script that is in the directory you installed
zope into.

In your case it will be:

  /home/jonano/Zope-2.1.6-src/stop

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Unique id product

2000-07-02 Thread Steve Alexander

Hi Kent,

Kent Sin wrote:
 I want to develope a unique sequence id generator product, I have the
 following code

 def newid(self, increment=1):
 """ return new id """
 self.counter = self.counter+increment
 return self.counter
 
 I am not quite sure if this works when more than one process asking for a
 newid concurrently. 

Do you need unique sequential ids, or will just unique ids do?

The problem with sequential ids is that you need to store the next id in
the sequence somewhere, and access to and incrementing this value
becomes a performance bottleneck for your server.

Also, if you store the sequence value in the ZODB, you will be creating
an undo record each time the id is incremented, and this is an
additional performance and storage overhead.

If you just want ids that are unique to a folder, try the following
algorithm (taken originally from the Discussion object code in the PTK).
The variable "self" is the one passed to the constructor method of a
particular Python class, and represents the folder you want to put the
new object into. I'm assuming the object is a "FooBar Item". The
"foobar-%06d" bit generates a unique id for the object that looks like
"foobar-290172837", based on the current time.

id = int(DateTime().timeTime())
while hasattr(self, str(id)):
id = id +1
id = 'foobar-%09d' % id


The advantage of this approach is that there is very little contention
in most cases.

 Is that zodb automatically serial all transaction?

For the purposes of generating ids, yes.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: Traversal of ZODB

2000-07-04 Thread Steve Alexander

On Fri, 30 Jun 2000, David Trudgett wrote:
 I wonder if anyone has a sample Python script that traverses the ZODB to 
 query or perform arbitrary operations on the objects found in it? My 
 present requirement is to write a script that goes through and does some 
 automated updating of several dozen DTML documents.

Hi David,

I just posted something similar to Zope-Dev:

  http://lists.zope.org/pipermail/zope-dev/2000-July/005744.html


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Re: Traversal of ZODB

2000-07-05 Thread Steve Alexander

Hi David,


David Trudgett wrote:
 
 Some questions I have in my mind:
 
 1. I used "raw" and you used "PrincipiaSearchSource()" . The reason I used
 raw was because I wanted to be sure that what I got wasn't munged in any
 way, and that what I put back reflects what was actually there before.

Sounds fair enough.
I really shouldn't have used PrincipiaSearchSource(), as the method name
doesn't reflect the function I wanted it to perform. The method
read_raw() would have been more appropriate.

However, my background developing Java applications programs causes me
to favour calling methods to directly pulling in attributes. I *know*
the Python idiom, but I'm not completely comfortable with it yet :-)


 2. You used the "manage_edit()" method, whereas I just assigned to the
 "raw" property. My way seems to work OK, but I'm not sure how yours works:
 I assume it brings up an edit page in the browser for each document?

My external method isn't returning anything, and isn't passing a REQUEST
or a RESPONSE, so there is nothing returned to the browser at all.

A better version of the external method would return a nicely formatted
status message to the browser.


The difference between setting "raw" directly and using manage_edit() is
that the latter will parse and check the syntax of and save a cooked
version of the DTML. As you just directly set the attribute "raw", you
*might* find that your change aren't all reflected in the operation of
the methods you've changed. However, as you've only changed some HTML
formatting, this shouldn't be a problem with what you've done as yet.

Using manage_edit() will also alert you to invalid syntax in your
changed version by raising a ParseError, that will be visible in the
browser.

If there are additional triggers in a class to get it recatalogued in
various special ways, these might only be triggered from methods like
manage_edit(), whereas setting an attribute will only trigger standard
catalogue awareness.

 3. I don't like resorting to testing the "meta_type" for a particular
 string value. As you noted in your code, it doesn't allow for subclassing,
 so it's not fully general.

I agree somewhat. However, I think that testing the meta_type is the
most Zope-friendly way to do it :-)
For example, in a pathological case, I could write a Python class in a
Product that ostensibly inherits from DTML Method, but completely
changes the way the attribute "raw" is used.

 4. I was surprised that the import statement (not to mention
 "re.compile()") could be put outside of the method definition, considering
 that Zope's external methods grab on to individual methods within a Python
 module.

Think about the way Python loads in functions and classes: the file gets
read into the interpreter, and statements get executed (which runs
them), whilst function definitions get executed (which causes their
definitions to appear in the namespace somewhere).

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Is Zope slow?

2000-07-06 Thread Steve Alexander


Firestar wrote:
 Check out Jakob Nielsen's website and you would know that speed of serving
 webpages is one of the main usability factors.

The bottleneck is not generally the speed of serving webpages, but
rather, the speed of the client downloading the data from webpages, as
the data has to go through N regions of the Internet between the server
and client.

Also, users tend to look at more than one webpage at a time, and so
their incoming bandwidth per connection is reduced even further.

The answer to this issue is to avoid large graphics and large pages,
allow client-side caching, move the useful content of a site "forwards"
towards its entrance, avoid banner adverts...

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] cr/lf causing spaces

2000-07-09 Thread Steve Alexander

You can put your linefeeds inside the HTML and DTML elements:

h2This is a really long heading with a dtml-var foo
 dtml variable in it/h2


See http://www.cat-box.net/helen/notes.html#source_layout_notes for more
information about these issues.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Another DateTime Strangeness

2000-07-09 Thread Steve Alexander

Nils Jeppe wrote:

 Zope just stored a DateTime I entered as 13:14 in a slightly odd way:
 
 2000/07/09 13:13:60 GMT+1

 Known bug?

Yes. What version of Zope are you running?

Shane Hathaway did a line-by-line audit on DateTime.py, and fixed loads
of timezone and rounding bugs. The fixed version is available in CVS and
in Zope 2.2.x.

There was also a copy of it on Shane's page at www.zope.org, but it is
gone now.

If you get stuck, mail me privately and I'll send you the fixed version.

You're better off getting it from a copy of Zope 2.2, if you can.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] ZWiki/Structured Text formatting surprise

2000-07-11 Thread Steve Alexander


Jim wrote:
 A number of people have complained about the use of single quotes
 for in-line code. One possible alternative is to use ``code''.

I like the way it looks.

However, I think it causes a problem with code like this:

  `` if a == '': doSomething() ''

You could use ``code`` instead, though.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: LoadSite can create a corrupted data.fs ?

2000-07-12 Thread Steve Alexander

Jonathan,

I'd be really really surprised if LoadSite can create a corrupted
data.fs. I really do not think this is where the problem lies.

LoadSite does not directly interact with the Zope persistence machinery.
It really doesn't do that much different than manually uploading loads
of files. Even if something were faulty in the tool you used to upload
the files, Zope itself would reject the file, or store incorrect data;
but either way, the data.fs would remain intact and self-consistent.

However, when you upload 900 files in one go, no matter how, you are
using a lot of the resources on your computer. You're probably
exercising quite a lot of the cache and memory.

Have you checked carefully whether you have that Intel mainboard
hardware fault that was mentioned to you a few days ago? If your
hardware has this fault then just occasionally, you will be writing
faulty data.

You must get your hardware checked, or else this problem will most
likely occur again.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] .dtml files

2000-07-12 Thread Steve Alexander


Daniel wrote:
 During this process I have noticed that Zope's dtml pages are stored on
 the file system as .dtml files (i.e. roleEdit.dtml) The question then is
 how does Zope display this pages??

The pages are usually accessed as attributes Python objects. They are
wrapped in a HTMLFile instance.

(Line numbers refer to latest Zope 2.2b4).

For example, see line 191 of lib/python/OFS/DTMLMethod.py:

  manage_editForm=HTMLFile('documentEdit', globals())

See the source in lib/python/DocumentTemplate/DT_HTML.py for details.
The documents are read lazily.

class HTMLFile(FileMixin, HTML):
"""\
HTML Document templates read from files.

If the object is pickled, the file name, rather
than the file contents is pickled.  When the object is
unpickled, then the file will be re-read to obtain the string.
Note that the file will not be read until the document
template is used the first time.
    """
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: [Zope-dev] passing namespace

2000-07-15 Thread Steve Alexander

danchik wrote:
 
 if I submit a form to some page that has frames, how do I pass the
 REQUEST namespace to those frames

Danchik,

You've posted this question to the [EMAIL PROTECTED] list. This mailing
list is about the technical internals of Zope, and developing new Zope
products.

Your question is more to do with using Zope as a web developer.

You're more likely to get a useful response to your question if you post
it to the [EMAIL PROTECTED] mailing list. I've cc-ed this message to that
list instead of the zope-dev list.

Also, I'd find it helpful to know what you have already tried, and what
didn't work when you tried it. A simple example that demonstrates the
problem would help too.

Have you looked in the mailing list archives? Perhaps your question has
already been answered there? Here's a link to a searchable archive.

  http://zope.nipltd.com/public/lists/zope-archive.nsf/

I searched just now for "request and frames", and there were a number of
helpful-looking results.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: LoadSite can create a corrupted data.fs ?

2000-07-20 Thread Steve Alexander

Jonathan Desp wrote:
 
 Thanks alot !
 
 Do you know how to put a small description for each results you are getting
 on a search engine, if you go to www.atomasoft.com and search
 "Nanotechnology" you'll get several several result, but with no description
 like at my past site www.atoma.f2s.com if you try the search engine you'll
 see good description which is a must.
 
 So do you know a way or the script or ? you'll be very useful if you know
 how.

Read the ZCatalog Tutorial and the Advanced ZCatalog Tutorial.

You can find them by searching on www.zope.org.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] re: Meta Type Registry

2000-07-22 Thread Steve Alexander

Andrew Kenneth Milton wrote:
 
 Is there a Product Builders meta-type registry somewhere?
 
 I can see things getting messed up in the near future as the number of
 products proliferates and meta-types start to clash.

I just tried adding a new ZClass in a new Product in my Zope 2.2 final
installation.

The multiple-selection widgit for choosing the base-classes has all the
available meta-types prefixed with the name of their product, followed
by a colon.

For example, here's the list I get:

  AccessControl: User
  AccessControl: UserFolder
  OFS: DTMLDocument
  OFS: DTMLMethod
  OFS: Folder
  OFS: File
  OFS: Image
  ZCatalog: CatalogAware
  ZCatalog: ZCatalog
  ZPatterns: DataSkin
  ZPatterns: PlugInBase
  ZPatterns: PlugInContainer
  ZPatterns: Rack
  ZPatterns: Specialist
  ZClasses: ObjectManager

So, it looks to me like the problem of meta-types clashing is taken care
of, at least in principle.
I note that the management screens' "add" drop-down list doesn't have
the "product:" namespace qualification, and I guess that's where the
problems lie. I doubt this would be much of a problem to patch, and it
probably counts as a bug, if anyone is passing the Collector in the near
future.

Now, we might want to consider a product naming registry to address the
problem of product names that clash...

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: Meta Type Registry

2000-07-22 Thread Steve Alexander

Steve Alexander wrote:
 
 Andrew Kenneth Milton wrote:
 
  Is there a Product Builders meta-type registry somewhere?
 
  I can see things getting messed up in the near future as the number of
  products proliferates and meta-types start to clash.
 
 I note that the management screens' "add" drop-down list doesn't have
 the "product:" namespace qualification, and I guess that's where the
 problems lie. I doubt this would be much of a problem to patch, and it
 probably counts as a bug, if anyone is passing the Collector in the near
 future.

Patch against 2.2 final. It isn't perfect, but it is minimal and
functional :-)

This changes the "add" drop-down on the management screen to give you
the product name (usually) followed by a colon, followed by the
meta-type.


*** lib/python/OFS/main.dtmlSat Jul 22 23:50:17 2000
--- lib/python/OFS/new_main.dtmlSat Jul 22 23:50:13 2000
***
*** 96,102 
/'+this.options[this.selectedIndex].value"
  OPTION value="manage_workspace" DISABLEDAvailable Objects
dtml-in filtered_meta_types mapping sort=name
! OPTION value="dtml-var action fmt="url-quote""dtml-var name
/dtml-in
/SELECT
INPUT TYPE="SUBMIT" VALUE=" Add "
--- 96,103 
/'+this.options[this.selectedIndex].value"
  OPTION value="manage_workspace" DISABLEDAvailable Objects
dtml-in filtered_meta_types mapping sort=name
! OPTION value="dtml-var action fmt="url-quote""
!dtml-var product missing:dtml-var name
/dtml-in
/SELECT
INPUT TYPE="SUBMIT" VALUE=" Add "

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] re: Meta Type Registry

2000-07-23 Thread Steve Alexander

Andrew Kenneth Milton wrote:
 
 +[ Steve Alexander ]-
 | Andrew Kenneth Milton wrote:
 | 
 |  Is there a Product Builders meta-type registry somewhere?
 | 
 |  I can see things getting messed up in the near future as the number of
 |  products proliferates and meta-types start to clash.
 |
 | I just tried adding a new ZClass in a new Product in my Zope 2.2 final
 | installation.
 |
 | The multiple-selection widgit for choosing the base-classes has all the
 | available meta-types prefixed with the name of their product, followed
 | by a colon.
 
 I'm not sure that Zope will actually let you successfully register two
 classes or baseclasses with the same meta-type... 

The meta-type is further qualified by the name of the Product. This
works without a problem if you're writing Python products, but there are
some difficulties if you want to have two ZClasses with the same name.

We can do a short experiment using ZClasses to check this. I'm using 2.2
final.

First of all, install the patch I posted to the Zope list last night.
That is, with lib/python/OFS/main.dtml at line 98 change this:

  dtml-in filtered_meta_types mapping sort=name
OPTION value="dtml-var action fmt="url-quote""dtml-var name
  /dtml-in

to this:

  dtml-in filtered_meta_types mapping sort=name
OPTION value="dtml-var action fmt="url-quote""
   dtml-var product missing:dtml-var name
  /dtml-in


Next, create a new Product from the management interface. Let's call it
"TheClash".

You can add a ZClass called DTMLDocument, meta-type "DTML Document" with
no problem.


In the Product "TheClash", create a new ZClass called "Casbah". Keep the
box "create constructor objects?" checked, but don't worry about adding
any base-classes.

Now, create another new Procduct called "Morocco". Within it, create a
new ZClass "Casbah".
If you leave the box "create constructor objects?" checked, you'll find
that creating the class fails with an error: "The permission Add Casbahs
is already defined."

However, you can create a ZClass "Casbah" in product "Morocco" if you
uncheck the box "create constructor objects?". This isn't too much of a
problem because it is easy to create our own custom permissions for
ZObject constructors. I won't bother doing that now. We can borrow the
other Casbah's permissions if we need to.

The new "Morocco: Casbah" won't show up in the "add" list yet, because
there is no Factory for it. Let's create a Factory in the Product
"Morocco", with id "Casbah_factory", title "Casbah factory".

For now, it doesn't matter what "Initial method" is set to. Leaving it
as "Help" will be ok for the purposes of this exercise.

The problem comes with what we put in the "add list name" field. If we
put in "Casbah", we get an error "The type Casbah is already defined".
We can put in "Casbah2" though, and that works.

Of course, is isn't practical if you simply want to use someone else's
Product on your Zope installation, and you already have a ZClass
meta-type defined that clashes with one in the new Product.

I just peeked at the source for this system
(lib/python/App/ProductRegistry.py, line 130 or thereabouts). The
Product Registry seems to add new meta-types based on the meta-type
alone, whereas they should be organised by a (product, meta-type) tuple.
This would fit with the way product constructors are called, for
example: "manage_addProduct/Morocco/Casbah_factory".

I won't produce a patch for this just now, as I'm not sure what other
parts of Zope are dependent on the current behaviour of not allowing
meta-type clashes in ZClasses. I do not think it would be hard to
improve the current behaviour.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] ZClasses to RDBMS

2000-07-25 Thread Steve Alexander


Satheesh Babu wrote:

 Is there any recommended way to get data from ZClass instances to a
 corresponding RDBMS (Oracle 8i specifically) table?

 What I could think of as options are: (I've'nt tried out any!)
 1.  In manage_add for my Zclass call the corresponding ZSQL insert method
  - Can this be done?
  - What can be done for updates?
 2.  Create masking DTML methods to create Zclass instances dynamically.
  Call ZSQL methods alongside as well.
 3.  Do periodic downloads of ZClass instances - say XML format - and batch
  upload to database.

This sounds like a job for ZPatterns:

  http://www.zope.org/Members/pje/ZPatterns

Most people find ZPatterns a bit difficult to get started with. It is
also alpha-release software, so *caveat emptor*.

Read the ZPatterns wiki too.

  http://www.zope.org/Members/pje/Wikis/ZPatterns/HomePage

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: Where should votes be posted? (was: Your feedback on datetime)

2000-07-25 Thread Steve Alexander

Brian Lloyd wrote:
 
  Do we *have* to clutter this [EMAIL PROTECTED] list up with loads
  of votes?
 
  It is high enough traffic as it is!
 
 That is a good point. My initial reaction is to say that
 maybe voting should only be done on zope-dev, but I worry
 a bit that there may be quite a few people on the zope list
 (and not on zope-dev) who would have a stake in an issue and
 end up not seeing (or voting) on it.

I agree there.

 Ideally I'll have a web-based voting thing on dev.zope.org
 so that only one pointer to it has to go to the list(s), but
 until then I propose that votes happen on zope-dev for the
 time being...

Sorry that I wasn't very clear. My point is whether everyone has to mail
their votes to the list, or whether they can just mail them to you. You
collate the votes and post the result to the list after a period of
time.

But then, perhaps people like seeing how popular the proposal is, in
real time :-)

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: [Zope-dev] Need for aq_base in DTML(was: Re: [Zope] Dumb DTMLquestion - existance check of an object)(was: Re: [Zope] Dumb DTMLquestion - existance check of an object)question - existance check of an object)(was: Re: [Zope] Dumb DTML question - existance check of an object)

2000-07-26 Thread Steve Alexander

Dieter Maurer wrote:
 
  * Access to "/": "PARENTS[-1]"
  * Existence check: "_.hasattr(object,what)"
  NOTE, that this is the sloppy part.
 
   - "_.hasattr" will return true, if "object" has
 attribute "what" (that is what we want)
 *OR* when it has acquired such an attribute
 (we do *NOT* want that here).
 
 What we would need is a DTML accessible version
 of "aq_base". This is trivially handled by
 an external method.

Can you do this with the following in DTML?

  dtml-with "PARENTS[-1]" only
dtml-if "_.hasattr(object, what)"
    ...stuff...
/dtml-if
  /dtml-with

Not tested, but it looks right to me.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: Displaying Lines? was: form to a email in a correct

2000-07-28 Thread Steve Alexander

Tim Cook wrote:
 Other than iterating through the property is there a way to
 display or present the lines property for edit without the
 containing ['brackets', '', 'ticks']? s

Something like this:

  dtml-var "_.string.join(lines_property, 'br')"

or this:

  dtml-var "_.string.join(lines_property, '\n')"

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Pasting renderable

2000-08-01 Thread Steve Alexander

I don't think it is just Renderable ZClasses.

Can you paste ZClass instances at all in Zope 2.2.0?

See my message in Zope-Dev: 

  http://lists.zope.org/pipermail/zope-dev/2000-July/006238.html

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Client.py

2000-08-09 Thread Steve Alexander


bak wrote:
 has anybody successfully used Client.py that ships with Zope-2.2.0?  i can't 
 seem to run it.  even on the command line.  i've searched the mailing list, 
 but to no avail

There's a bug in Client.py.

Change line 212 of lib/python/ZPublisher/Client.py from this:

h.connect((self.host, self.port))

to this:

h.connect(self.host, self.port)


I believe this is already fixed in Zope CVS.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: [Zope-dev] RE: Request for Comment: Zope API naming convention

2000-08-09 Thread Steve Alexander

Chris McDonough wrote:

  Please make comments by Wednesday April 16.
 
  Jim
 
 Plenty of time...  :-)

Especially considering that the next Wednesday April 16 is in 2003.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] List

2000-08-10 Thread Steve Alexander

 William Joye wrote:
 
  Hello,
  
  I'm a newbie in zope. I think is a simple problem but I can find a solution.
  I would like to show 2 lists (ex: list1 and list2) like this :
  
  list1 = 1, 2, 3,...
  list2 = A, B, C,...
  
  list1 + list2 =
  
  1 A
  2 B
  3 C
  
  How can I iterate 2 lits in one dtml-in ?

Kapil wrote:

 for me the easiest way seems to combine the two lists and iterate over
 the results in a dtml in. problem is that doing this in dtml is hard
 cause of safety restrictions, in python its pretty slack though. here is
 a web python method that does the list work.

 name: combine
 args l1, l2
 return map( (lambda x,y:(x,y)), l1, l2)

 and the dtml

 dtml-in "combine(list1, list2)"
 dtml-var sequence-key - dtml-var sequence-item
 /dtml-in

You can also do this:

dtml-in list1
  dtml-var sequence-item - dtml-var "list2[_['sequence-number']-1]"
br
/dtml-in


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] ZClass inheriting from image question

2000-08-11 Thread Steve Alexander


Kapil wrote:
  I want to change the default way the ZClass renders it's information. I
  want more than simply a picture so I crated a new method "index_html" in
  my ZClass.
 
  My question is: How do I display the picture from this index_html method?


http://www.zope.org/Members/lalo/Renderable-ZClass

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] The date in Dutch

2000-08-18 Thread Steve Alexander


Michel Houben wrote:
 How can I fix the date in Dutch, for example Donderdag 17 Augustus 2000 
 instead of Thursday 17 August 2000. I hope someone can solve this problem.

I don't know any Dutch.

However, here's an external method that will convert the months and days
of the week in a string from English to German.

There are probably better names for the variables and such, so don't
take this as as example of clear maintainable programming :)

It ought be be pretty efficient.

Assuming you call the external method D_date, use something like this:

  dtml-var "D_date('October February July, Tuesday, 23 March 2000')"


import re

# you can remove lines where the words are the same in both languages
replacements={
'Monday':'Montag',
'Tuesday':'Dienstag',
'Wednesday':'Mittwoch',
'Thursday':'Donnerstag',
'Friday':'Freitag',
'Saturday':'Samstag',
'Sunday':'Sonntag',
'January':'Januar',
'February':'Februar',
'March':'Mauml;rz',
'April':'April',
'May':'Mai',
'June':'Juni',
'July':'Juli',
'August':'Augustus',
'September':'September',
'October':'Oktober',
'November':'November',
'December':'Dezember'
}

class re_stored:
  def __init__(self, e, d):
self.d = d
self.regex=re.compile(e)

  def r(self, s):
return self.regex.sub(self.d, s)

replace_regexes=[]
for e,d in replacements.items():
replace_regexes.append(re_stored(e,d))
   

def D_date(datestring):
return reduce(lambda x,y: y.r(x), replace_regexes, datestring)


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] The date in Dutch

2000-08-18 Thread Steve Alexander

Sent again -- here's a slightly more compact version, that avoids
declaring a separate class to hold the expressions in.

Michel Houben wrote:
 How can I fix the date in Dutch, for example Donderdag 17 Augustus 2000 
 instead of Thursday 17 August 2000. I hope someone can solve this problem.

I don't know any Dutch.

However, here's an external method that will convert the months and days
of the week in a string from English to German.

There are probably better names for the variables and such, so don't
take this as as example of clear maintainable programming :)

It ought be be pretty efficient.

Assuming you call the external method D_date, use something like this:

  dtml-var "D_date('October February July, Tuesday, 23 March 2000')"



import re

# you can remove lines where the words are the same in both languages
replacements={
'Monday':'Montag',
'Tuesday':'Dienstag',
'Wednesday':'Mittwoch',
'Thursday':'Donnerstag',
'Friday':'Freitag',
'Saturday':'Samstag',
'Sunday':'Sonntag',
'January':'Januar',
'February':'Februar',
'March':'Mauml;rz',
'April':'April',
'May':'Mai',
'June':'Juni',
'July':'Juli',
'August':'Augustus',
'September':'September',
'October':'Oktober',
'November':'November',
'December':'Dezember'
}

replace_regexes=[]
for e,d in replacements.items():
replace_regexes.append(
eval("lambda x: re.compile('%s').sub('%s', x)" % (e, d)))

def D_date(datestring):
return reduce(lambda x,y: y(x), replace_regexes, datestring)


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] The date in Dutch - last time!

2000-08-18 Thread Steve Alexander

Ok... this is the last time.

You can put a line:

del replacements

just after the for loop, and save a tiny amount of memory.
This might be a useful optimisation if you're dealing with a very large
list of words to replace.


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] The date in Dutch - really last time!

2000-08-18 Thread Steve Alexander

Ok... this is *really* the last time.

I don't know why I was using a regular expression, when string.replace
would have done just as well. Here's my final version of the external
method. I *promise* I won't change it again.

Of course, the simplest version would be

from string import replace
def D_date(datestring):
 datestring=replace(datestring, 'Monday', 'Montag')
 datestring=replace(datestring, 'Tuesday', 'Dienstag')
 # und so weiter

However, this would be slower to execute than using "reduce", as below.


from string import replace

# you can remove lines where the words are the same in both languages
replacements={
'Monday':'Montag',
'Tuesday':'Dienstag',
'Wednesday':'Mittwoch',
'Thursday':'Donnerstag',
'Friday':'Freitag',
'Saturday':'Samstag',
'Sunday':'Sonntag',
'January':'Januar',
'February':'Februar',
'March':'Mauml;rz',
'April':'April',
'May':'Mai',
'June':'Juni',
'July':'Juli',
'August':'Augustus',
'September':'September',
'October':'Oktober',
'November':'November',
'December':'Dezember'
}

replace_fns=[]
for e,d in replacements.items():
replace_fns.append(
eval("lambda x: replace(x, '%s', '%s')" % (e, d)))
del replacements

def D_date(datestring):
return reduce(lambda x,y: y(x), replace_fns, datestring)



--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] The date in Dutch

2000-08-19 Thread Steve Alexander

Michel Houben wrote:
 
 I am just beginning with Zope, so this is maybe a very stupid question;
 How do I make a external method, I don't know what I must fill in, in two
 fields "Python module file" and "Function Name", I hope you can solve this
 problem for me.
 
 I thank you for your help,

First, make sure you have a subdirectory "Extensions" in your Zope
installation.
Here's the directory listing for mine. Make sure that "Extensions" is
there.

Extensions   access  libutilities   wo_pcgi.py   zpasswd.py
LICENSE.txt  doc pcgi   var wo_pcgi.pyc  zpasswd.pyc
README.txt   import  start  w_pcgi.py   z2.py
ZServer  inststop   w_pcgi.pyc  z2.pyc

Using a text editor, create a new file inside "Extensions" called
"D_date.py".
Put the code of the external method into D_date.py. Save it.

If you're on a unix system, make sure that you add the folder and add
the file as the appropriate user. This is often "nobody" or "zope".

From your Zope management web pages, add an external method to the root
of your zope instance. Let's call it "D_date". (You can call it anything
you want, so long as it is a valid zope id.)

Fill in "D_date" (without the quotes) as both the python module name,
and the function name.

See also here:

  http://www.zope.org/Documentation/How-To/ExternalMethods

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Anyone tried Tomahawk

2000-08-21 Thread Steve Alexander

Anyone tried Tomahawk yet?

  http://freshmeat.net/projects/tomahawk/

Tomahawk is an Apache-based Web server with integrated Squid object
cache capabilities running on an intuitive Web-based UI. As well as
dramatically increasing server performance, Tomahawk simplifies the
operation of maintaining an object-cache accelerated Web server.

There's also http://anemone.electricc.com/ for real-time reporting.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: Stupid SiteAccess Question

2000-08-23 Thread Steve Alexander


Terry Babbey wrote:
 OK. I just downloaded SiteAccess 2.0.0b3 and untarred it in my Zope
 directory. I shutdown and restarted Zope but when I go to Control
 Panel/Manage Products I do not see SiteAccess listed. AM I missing
 something here ( quite probable )?

The latest SiteAccess is packaged a little differently from most other
products.

Most products are created with the idea that you will untar them in your
Zope directory, adn they will put themselves in
lib/python/Products/ProductName.

SiteAccess just puts itself in the directory SiteAccess.

Therefore, you need to untar the siteaccess archive in your
lib/python/Products directory.

Seeing as you've already done this, you can simply move the SiteAccess
folder from one level below your Zope installation folder, and put it in
your Products folder.

The reason SiteAccess is this way is that it provudes better
compatibility with using INSTANCE_HOME to share a single bunch of code
between many Zope instances.

From the CHANGES.txt file:

* The tarball no longer includes 'lib/python/Products' in file
paths.  It must be unpacked in the Products directory, for
better compatibility with INSTANCE_HOME installations.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: Can't compare apples to apples. (document_id != id_of_my_document)

2000-08-24 Thread Steve Alexander


T.J. Mannos wrote:

 I have a DTML document called "apples".

 A call to dtml-var document_id gives the string "apples"

 However, a dtml-if "document_id == 'apples'" returns false.  Am I missing
 something?  I've tried _.str(document_id) and even
 _.string.strip(_.str(document_id)).

The tag dtml-var document_id gets a value for document_id, and looks
to see if it is callable. If so, it calls it and returns the result of
calling it. If not, it just returns it. This is a feature of dtml-var
name="whatever", which is another way of writing dtml-var whatever.

However, when you use an expression, such as you are doing in the
dtml-if tag, you are writing in Python, and you need to call an object
if it ought to be called.
An expression is something like dtml-var "expression" or dtml-var
expr="expression, which are equivalent. The same goes for dtml-if
"expression".

In your case, you might find that this works:

dtml-if "document_id() == 'apples'"

Or perhaps this:

dtml-if "document_id(_.None, _) == 'apples'"

The reason is that ids ought always to be simple string objects, but
some aren't. There are lots of legacy programs that rely on some ids
being methods, so the odd cases won't be changed for a while yet.

The general answer is to use a special function that calls the value if
it is callable.

You have a choice here. These are equivalent.

dtml-if "_['document_id'] == 'apples'"

dtml-if "_.getitem('document_id', 1) == 'apples'"


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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 )




[Zope] Re: ZCatalog - OR'ing on different columns (indices)

2000-08-25 Thread Steve Alexander

Aleksander Salwa wrote:
 Is there any better method of OR'ing on differend indices in quering
 ZCatalog, then the method described in 'Advanced ZCatalog Searching'
deletia

 It seems to me to be common case, when we show to user simple search form
 with only one input (that is where 'userInput' came from) and 'Go!'
 button. User don't want to know, that we have our data splited in many
 properties. But on Zope side it's very good to have it structured in that
 way - so how to reconcile these things ?


I use more than one ZCatalog at a time. One called SiteSearch stores
full-text-search information on all the objects in a site. Then, I have
other ZCatalogs for domain-specific searches.

I use ZPatterns to do this.

My objects are derived from DataSkins. I use CatalogTriggers to index my
objects in the appropriate catalogs. CatalogTrigger is from Itamar
Shtull-Trauring's ZPAddons package. (There will be a new version of
this, renamed DataSkin addons released this weekend.)

You could also modify CatalogAwareness.py to make an object aware of
several catalogs at once.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] how to keep stuff out of undo

2000-08-30 Thread Steve Alexander

Roman Milner wrote:

 Hi. We have a product (an mp3 jukebox) that uses the ZODB to store a large
 data structure of all the albums and track names.  Many people are
 allowed to add/remove albums from the database.  The problem is, when
 they do this the entire data structure is backed up for undo.  So, by
 the end of each day, our ZODB has grown so large we are out of disk space.

The way I'm reading this, you have this entire database of albums and 
tracks as a sinle object in your ZODB.

Don't do that.

Refactor your product to use subobjects of your Jukebox object as 
albums, and subobjects of those as tracks.

Then, only a small amount of data gets rewritten on each transaction.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Slow zope.org?

2000-09-02 Thread Steve Alexander

ethan mindlace fremen wrote:

 
 Short term, we will soon have a mirror of zope.org, which should reduce
 the possibility of slowdown. 

What kind of mirroring?

Something static, or something clever using ZEO?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Could someone explain this DateTime behaviour to me?

2000-09-05 Thread Steve Alexander

Dario Lopez-KXsten wrote:

 AS in is this the expected/intended behaviour or could this be classified as
 a bug?
 
 
 ---
 
 bobobase_modification_time
   2000/09/02 08:49:48.326 GMT+2
 
 bobobase_modification_time().toZone('GMT+2')
   2000/09/02 12:49:48.326 GMT+2
 
 bobobase_modification_time fmt="%Y-%m-%d %H:%M"
2000-09-02 12:49
 
 ---

What version of Zope are you using?

Various timezone bugs in DateTime.py were fixed in the latest version of 
Zope.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] 'showREQUEST' or 'show_REQUEST' ?

2000-09-11 Thread Steve Alexander

Chris Withers wrote:

 Jason Cunliffe wrote:
  PS. Be warned: 8-()
   if you try put the code above in a DTML methods named 'showREQUEST' or
  'show_REQUEST' it will not work = 'Id already in use'
 
 That's a little weird...
 
 Can anyone shed any light on this?

I get an error when I try to add a DTML Method with REQUEST anywhere in 
the id.

Actually,  the method gets added, but I cannot edit it.

I haven't found out why yet.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] restrictedTraverse - yay! :-)

2000-09-15 Thread Steve Alexander

Dennis Nichols wrote:
 
 At 9/15/00 10:05 AM, Chris Withers wrote:
 So:
 
 dtml-var "restrictedTraverse('slash/delimited/path')" absolute_url
 
 will work as I expect it to?
 
 Well, I don't know what you expect :-) When I try to save such a construct
 with the handy-dandy Change button I get
 
 Document Template Parse Error
 Invalid attribute name, "absolute_url", for tag dtml-var
 "restrictedTraverse(choice)" absolute_url ...

Yeah. That's right. There is no attrubute absolute_url.

There is, however, a method absolute_url().

This should do what you expect:

dtml-var "restrictedTraverse('slash/delimited/path').absolute_url()"

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Restricting URL access to objects that are not complete web pages

2000-09-21 Thread Steve Alexander

Stephen Simmons wrote:

  
 Any suggestions? Something involving permissions/roles? Hacking
 before_bobo_traverse()? Something simpler?

You could use SiteAccess for this; get it to match the allowed paths and 
patterns to those documents you want available directly through the web, 
and return a 404 to those that don't match.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Restricting URL access to objects that are not complete web pages

2000-09-21 Thread Steve Alexander

Stephen Simmons wrote:
 
 Steve,
 
 Ideally the publishability of an object would be an internal property of
 that object, not something that is set externally via rules in SiteAccess.
 It's been a little while since I last looked at SiteAccess, but wouldn't
 using SiteAccess force you to store publishable objects in one part of the
 database hierarchy and non-publishables in another? If you wanted
 publishables and non-publishables all mixed up in the same folders,
 SiteAccess's rules might get a bit complicated.

Yes, this is not a neat solution, unless you have already designed your
site to use siteaccess in this way.

 Another approach could be to:
 - create a folder that does a RESPONSE.setStatus(404) as the URL traversal
 machinery passes it. This sets up the default condition of 'NotFound' error
 for the URL
 - at the end of the URL, if the final object is publishable or the final
 item is a publishable method called on a publishable object, do a
 RESPONSE.setStatus(200) to say 'OK'.

Even if you don't reset the status to 200 and it remains as 404, the
page will still get sent to the browser. You don't want to mess with the
traversal machinery on this, as you want traversal to continue to work
as it does now.

I think your intent is to block direct requests from a web-browser for
particular objects. The easiest way of doing this is to check
REQUEST.steps[-1] to see if it equals the current object's id.

If you want this to be fairly transparent, perhaps based on a particular
permission or property, then I think you'll need to patch part of Zope,
probably HTTPRequest.py.
 
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] standard_error_message confusion

2000-09-22 Thread Steve Alexander

Danny William Adair wrote:
 
 My standard error_message is ok.
 
 I think my problem with LoginManager and Membership can be cut down to this:
 
 If I take away all permissions from a dtml-document for Anonymous, he will
 be correctly prompted for Login using *my* standard_error_message
 ("LoginRequired" is raised) as soon as he tries to access it. _But_, if I
 take away the rights for Anonymous from a _folder_ under which a dtml
 document acquires these security settings, he'll get the hard-coded Zope
 error_message with the login field, instead of my (customized one). Whassup?

In the latter case, does Anonymous have rights to view your
standard_error_message?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] standard_error_message confusion

2000-09-22 Thread Steve Alexander

Danny William Adair wrote:
 
 Unfortunately, yes he does.

Time to step through your site in the debugger then. Or, instrument
HTTPRequest.py and HTTPResponse.py to see what is getting called when.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Problem with properties in inherited ZClasses

2000-09-23 Thread Steve Alexander

Stephen Simmons wrote:


 I have tried to create another ZClass, AdminTools:Task that inherits from
 AdminTools:Folder that adds some task tracking functionality and
 uses/overrides the AdminTools:Folder methods for displaying objects

I tend to try not to have ZClasses derive from other ZClasses. You'd 
find it more straightforward either to derive both ZClasses from a 
common Python base class, or to keep both ZClasses independent of each 
other.

In general, I try to avoid using inheritence. Python and Zope support 
polymorphism whether you derive classes from the same base-class or not. 
Also, I find the coupling introduced by inheritence more trouble than it 
is worth for the reduced redundancy.

I realize that I have avoided trying to answer why ZClasses work in this 
way.

   File D:\Dev\ZopeTestbed\lib\python\OFS\PropertySheets.py, line 235, in
 _setProperty
 (Object: Task)
 Bad Request: (see above)
 
 I don't understand why I can add the 'title' property to Task but not
 'description'.

Here's the code that is raising the exception:

if hasattr(aq_base(self),id):
if not (id=='title' and not self.__dict__.has_key(id)):
raise 'Bad Request', (
'Invalid property id, em%s/em. It is in use.' % id)

You can see that 'title' has a special status as a property.

 
 To conclude:
 
 (i) What is going on and how can I fix it?

Don't do things that way to start with.

 (ii) When using a ZClass as a base class, do instances inherit any
 properties, or do they just get access to the base class's methods? If
 ZClasses do inherit properties from parent ZClasses, how do I reach them via
 the property sheets?

If you add propertysheets to instances of your classes, rather than to 
the classes, then you don't get conflicts over attributes. However, 
unless you use ZPatterns or something like that, you have to refer to 
the attributes of propertysheets explicitly naming the propertysheet.

 (iii) Is there a simple way to find out what methods and properties an
 object has? I would like to see what it defines, what it inherits and what
 it acquires.

Yes. See the code above from PropertySheets.py. Use something like this 
in an external method to find out the attributes of an object. (In 
python, methods and fields are both attributes.) You can use the magic 
aq_* attributes of acquisition wrappers to walk through the objects that 
get considered during acquisition. You might also want to look at Shane 
Hathaway's Acquisition Explainer, an external method to show how 
acquisition works, that also demonstrates use of the aq_* attributes.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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] Help - Weird stuff.

2000-09-30 Thread Steve Alexander

Phil Harris wrote:

 Hi all,
 
 Sorry for the subject but I don't really know how to describe this.
 
 I have a folder 'hp' which has loads of stuff in it, if I try to copy and
 paste into it though I get this error:
 
 'The object index_html does not support this operation '

I can't reproduce this in Zope 2.2.2, linux.

Can you describe a simple case that has the problem?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.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-dev] Methods through the Web (security?)

2000-05-18 Thread Steve Alexander

Martijn Faassen wrote:
 
 Brian Lloyd wrote:
  Yes you could, except that you would also make them inaccessible
  from DTML (or from anywhere else) for the same class of users.
 
  Is it really acceptable that in order to use dtml-in objectIds
  on a page that needs to be accessible to anonymous users that I
  must grant 'Access contents information' to anonymous users and
  thus give them the ability to inspect my objects if they want to?
 
 So you have something like:
 
 'Access at all' (this is 'Access Contents Information')
 
 'Access through URL' (the 'expose' flag I talked about in previous posts)
 
 'Access through FTP'
 
 'Access through XML-RPC'
 
 etc.

This is an interesting idea --

The Zope server is an Object database that exposes objects and
attributes via various protocol modules.

I can see a future where you'd want to be able to plug in arbitrary
protocol modules -- and perhaps more than one instance of each type of
protocol (for example, http on ports 80 and 8080).

It would make sense to me for each protocol to have its own set of
"expose flags" or even "expose rules" for each addressable
object/attribute.

The user interface to manage the objects could collect these all into
one place, so as the manager of an object, you can decide what is
allowed to be seen via which protocols.

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] Zope 2.1.6 DateTime bug: daylight saving time not handled -- with patch

2000-05-29 Thread Steve Alexander

Dieter Maurer wrote:
 
 The Zope 2.1.6 DateTime module does not recognize daylight saving time.

You might find Shane Hathaway's revision of DateTime.py useful.

  http://www.zope.org/Members/hathawsh/DateTime.py

It corrects many rounding errors, as well as the problems with daylight
saving time.

I believe it is the version that will be in Zope 2.2

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] Repeating a piece of HTML code

2000-06-02 Thread Steve Alexander

Shane Hathaway wrote:
 
 Alex Mendez wrote:
 
  Hello, it's the first time I write here and I'm a
  newbie at Zope, so maybe I'm asking a stupid
  question...
 
  Case is I retrieve from my movie database the value of
  the movie from 1 to 5 stars. I would like to repeat
  that n times the code img SRC="star.gif" height=15
  width=15 so the number of stars would appear:
 
  1 - *
  2 - **
  3 - ***
  4 - 
  5 - *
 
  Is there any way to do so in Zope? Does the dtml-in
  tag anything to do with it?
 
 dtml-in expr="_.range(0, movie_rating)"
   img SRC="star.gif" height=15 width=15
 /dtml-in
 
 Replace movie_rating with the variable that represents the movie rating.

What about dtml-var "'*' * movie_rating" ?

--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] Repeating a piece of HTML code

2000-06-02 Thread Steve Alexander

Steve Alexander wrote:
 
 Shane Hathaway wrote:
 
  dtml-in expr="_.range(0, movie_rating)"
img SRC="star.gif" height=15 width=15
  /dtml-in
 
  Replace movie_rating with the variable that represents the movie rating.
 
 What about dtml-var "'*' * movie_rating" ?

Or rather:

  dtml-var "'img SRC=star.gif height=15 width=15' * movie_rating"

--
Steve Alexander
Software Engineer
Cat-Box limited

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

2000-06-02 Thread Steve Alexander

Another slightly different idiom is:

  dtml-var """'img src="foo.gif"' * 12"""  

It isn't very SGML-like though.


Jim Sanford wrote:
 
 You've got my vote. Being able to use """ would solve alot of my dtml coding
 headaches.
 
 Jim Sanford
 - Original Message -
 From: "Steve Alexander" [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, June 02, 2000 8:06 AM
 Subject: [Zope-dev] Using """string""" idiom in dtml
 
 How easy would it be to allow """python strings""" inside DTML tag
 attributes?
 
 I'm thinking particularly of situations like:
 
   dtml-var "'''img src="foo.gif"''' * 12"
 
 Currently, you need to mess about with _.chr(34) and string
 concatenation.
 
 The triple-quote idiom looks clearer to my eyes.
 
--
Steve Alexander
Software Engineer
Cat-Box limited

___
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] Prototyped folders?

2000-06-28 Thread Steve Alexander

Hi Hamish,

I've answered your message in Zope-Dev, as this seems to be more of a
developers' question.

Hamish wrote:
 If a folder doesn't itself contain a required object or method, I'd
 like to have another folder looked in instead. The fall-back folder
 won't necessarily (and often can't) be higher in the hierarchy, so
 acquisition doesn't seem to be a solution. 

This looks like a job for a Python class that uses the new Traversal
interface.

  http://www.zope.org/Members/michel/Projects/Interfaces/Traversal

Your requirements sound very much like those for Shane Hathaway's
Transparent Folders product, except that instead of briefly diverting
acquisition into the transparent folder, you want to briefly divert
acquisition into some other arbitrary folder.

Last I heard, Shane was going to revitalize Transparent Folders when the
various interfaces it uses are finalized for Zope 2.2.

I suggest that after Shane has re-released his product, you make a
product based on Transparent Folders that works in this slightly
different way. Or, if it is appropriate, consider your changes an
enhancement to Transparent Folders, and offer it as a patch.

If you don't have sufficient python-hacking-zope-hacking-Zen to do it
yourself, I think I might have a go (and hopefully learn some Zope
internals Zen in the process).

Transparent Folders were here:

  http://www.zope.org/Members/hathawsh/

 - but the link to them is broken -- I guess because the product was
withdrawn as there was a problem with it under Zope 2.1.6.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Racks and Specialists Simplified

2000-06-28 Thread Steve Alexander

Shane Hathaway wrote:
 
 "Phillip J. Eby" wrote:
  At 02:33 PM 6/11/00 -0600, Shane Hathaway wrote:
  I believe I have come to understand the basics of ZPatterns and would
  like to be sure I understand correctly, as well as help others
  understand also.
 
  Bravo!  An exquisite introduction to the purpose of ZPatterns.  May I post
  an edited version of your message to the ZPatterns Wiki, and make it or
  subsequently edited versions a part of the ZPatterns documentation?  (With
  attribution, of course.)
 
 By all means!  Thank you.  The truth is that several of us at DC have
 had trouble making sense of it all, so I wrote it not only for the
 community, but DC and myself as well. :-)

I just looked over the ZPatterns Wiki for Shane's explanation, but I
can't find it.

If it isn't there (hiding somewhere), perhaps I can add it from Shane's
original email?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] ZTopic displays wrong tabs

2000-06-28 Thread Steve Alexander

Hi folks,

I'm using ZTopic.

One thing I've noticed about the management interface is that, although
an appropriate tab is highlighted when you click that tab, if you go to
a subsequent screen, often "contents" will erroneously become the
highlighted tab.

This is causing problems as I explain to non-technical folk how to use
ZTopics. I say "select the contents tab", and they say "but the contents
tab **is** selected!".

I have a fix for this, but the real problem is in the logic of
lib/python/App/manage_tabs.dtml:

dtml-call "REQUEST.set('a_', 0)"
dtml-in manage_options mapping
dtml-if expr="URL[-(_.len(action)):]==action or
URL[-17:]=='/manage_workspace' and _['sequence-start']"
dtml-call "REQUEST.set('a_', _['sequence-index'])"
/dtml-if
/dtml-in

Here, the variable 'a_' represents the "active" tab. If the last part of
the URL matches one of the manage_options of the current object, then
that tab will be the highlighted one. Otherwise, the first tab will be
highlighted.

It should ideally be possible to tell manage_tabs what tab should be
highlighted, imperatively, when required.

However, in the absence of such a mechanism, I have changed the DTML
files in ZTopic like this:

The form searchEdit.dtml is really part of the "Search Criteria" logic,
so I want that tab highlighted. That tab's action attribute is called
"editForm". Therefore, in the file searchEdit.dtml, I replace this:

BODY BGCOLOR="#FF" LINK="#99" VLINK="#55"
!--#var manage_tabs--

pEdit catalog search criterion number dtml-var "index+1"
on Catalog strongdtml-var catalog_id/strong./p


With this:

BODY BGCOLOR="#FF" LINK="#99" VLINK="#55"
dtml-with "_.namespace(URL='editForm')"
  dtml-var manage_tabs
/dtml-with

pEdit catalog search criterion number dtml-var "index+1"
on Catalog strongdtml-var catalog_id/strong./p

(I modernised the !--#var ...-- to dtml-var ... along the way.)

To get the full effect, you'd need to do a similar trick with the other
dtml files in ZTopic.

Any takers for a full patch?  Or, is there a better way of doing this
that I don't know about?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] ZTopic displays wrong tabs

2000-06-28 Thread Steve Alexander

Steve Alexander wrote:
 
 BODY BGCOLOR="#FF" LINK="#99" VLINK="#55"
 dtml-with "_.namespace(URL='editForm')"
   dtml-var manage_tabs
 /dtml-with
 
 pEdit catalog search criterion number dtml-var "index+1"
 on Catalog strongdtml-var catalog_id/strong./p

Or, I could have used the less-clear one-liner:

  dtml-var "manage_tabs(_.None, _, URL='editForm')"

Any preference?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] adding attributes to a python product

2000-06-29 Thread Steve Alexander

Hi folks,

I have a Python Product that I'm developing. During the course of
development, I want to add a new attribute. All new instances get this
attribute, as it is defined with a default value in the constructor.

In addition, all instances that get edited via the web get the
attribute, as the edit-processing method is defined to have a default
value for this attribute.

Is there any way of interacting with the ZODB persistence machinery to
add the default attribute to all instances as they are brought out of
persistent storage -- so that I can just restart Zope, and have all of
my instances updated as I use them ?

I can't find the right method or whatever in the ZODB on-line docs, or
in the source.

Thanks for any help.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Product Data Storage

2000-06-30 Thread Steve Alexander

Andy Dawkins wrote:
 
 So my question is this:
 What are peoples opinions on storing shared product data?  Where should it
 be placed?  Should this ability be added to Zope as a standard?
 

So, this would be the zope equivalent of the unix "/etc/" directory?

Perhaps you could have "etc (Product Settings)" as a subfolder of
control panel.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Help needed: why is this DTML not working in zope 2 ?

2000-07-04 Thread Steve Alexander

Steve Alexander wrote:
 
 Gilles Lavaux wrote:
 
  Argh!!!
 
  no, I made a typo error : it was !--#var image_name--.the syntax was good.
  Ok, I will use the new syntax in my new sites. But for my old site, I will
  not modify my ~500 dtml methods, except if there is a way to automate the
  change.
 
 You can write a pretty simple external method to walk your Zope object
 heirarchy looking for DTML Methods and DTML documents, then altering the
 syntax. Shouldn't take more than an hour to write and debug and test and
 document, if you've written stuff in Python before.
 
 I'm off to a meeting for a few hours, but harrass me later and I'll send
 to the list a proof-of-concept external method to get you started.

An external method for automated change from old syntax to new syntax
follows.

 * Use at your own risk
 * No warranty implied or given
 * Use on a copy of your main Zope site
 * Back up data.fs three times before starting
 * Not guarenteed not to spin your processor and never terminate
 * Run on a copy of Zope in debug mode (-D) to see the print statements
 * Barely tested, if at all



import re

def convert_dtml(self):
"""Convert DTML Methods and DTML Documents from old syntax to 
   new syntax.
   Warning: recursive! Might just eat all your stack.
   Does not work on subclasses of DTML Method and DTML Document.
   Preserves normal comments, and handles instances of "--" in 
   quotes.
"""
print 'convert_dtml: id=%s' % self.title_and_id()
if hasattr(self, 'meta_type') and \
  (self.meta_type == 'DTML Method' or \
   self.meta_type == 'DTML Document'):
convert(self)

# should this be "isPrincipiaFolderish"?
if hasattr(self, 'isAnObjectManager') and self.isAnObjectManager:
for v in self.objectValues():
v.convert_dtml()

_convert_regex = re.compile('!--#(/?)(([^"-]+?|"[^"]*?"|-[^-])+?)--')

def convert(dtml_item):
print 'converting...'
title = dtml_item.title
   # like document_src, but doesn't require RESPONSE
data = dtml_item.PrincipiaSearchSource()
print 'data'
print data
newdata = _convert_regex.sub('\g1dtml-\g2', data)
print 'newdata'
print newdata
print 'end----'    
dtml_item.manage_edit(newdata, title)




--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Help needed: why is this DTML not working in zope 2 ?

2000-07-04 Thread Steve Alexander

Steve Alexander wrote:
 
 
 An external method for automated change from old syntax to new syntax
 follows.
 
  * Use at your own risk
  * No warranty implied or given
  * Use on a copy of your main Zope site
  * Back up data.fs three times before starting
  * Not guarenteed not to spin your processor and never terminate
  * Run on a copy of Zope in debug mode (-D) to see the print statements
  * Barely tested, if at all
 
 _convert_regex = re.compile('!--#(/?)(([^"-]+?|"[^"]*?"|-[^-])+?)--')

Actually, I missed something in the original regex, above. (Funny how I
noticed just after I pressed the 'send' button!)

It should read like this:

_convert_regex =
re.compile('''!--#(/?)(([^"-]+?|"[^"]*?"|'[^']*?'|-[^-])+?)--''')


The whole thing again -- same disclaimers apply, only more so :-)



import re

def convert_dtml(self):
"""Convert DTML Methods and DTML Documents from old syntax to 
   new syntax.
   Warning: recursive!
   This assumes that DTML Method and DTML Document haven't been
   subclassed.
"""
print 'convert_dtml: id=%s' % self.title_and_id()
if hasattr(self, 'meta_type') and \
  (self.meta_type == 'DTML Method' or \
   self.meta_type == 'DTML Document'):
convert(self)

# should this be "isPrincipiaFolderish"?
if hasattr(self, 'isAnObjectManager') and self.isAnObjectManager:
for v in self.objectValues():
v.convert_dtml()

_convert_regex =
re.compile('''!--#(/?)(([^"-]+?|"[^"]*?"|'[^']*?'|-[^-])+?)--''')

def convert(dtml_item):
print 'converting...'
title = dtml_item.title
   # like document_src, but doesn't require RESPONSE
data = dtml_item.PrincipiaSearchSource()
print 'data'
print data
newdata = _convert_regex.sub('\g1dtml-\g2', data)
print 'newdata'
print newdata
print 'end'
dtml_item.manage_edit(newdata, title)




--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] How to use document templates

2000-07-05 Thread Steve Alexander

Jarkko Veijalainen wrote:
 
 Hi!
 
 Where can i find S_I_M_P_L_E example of using document templates with
 zope/python. I have this external method, wich return several variables from
 object class. I want to embed to results in DTML page.
 
 The method is called from Zope by HTML form with 3 input attributes. Right
 now i have only managed to get obj.member in return plain screen. I can't
 use dtml-var tag, because i need to send those input values to the
 external method. ( i must be sound like real newbie, in fact i'm  :) )
 
 How i get those results in DTML page? Is the templates the answer or this
 there better way to this.

This question really belongs at on the [EMAIL PROTECTED] mailing list, as it
is to do with using Zope in a standard way, rather than developing Zope.


Sounds to me like you're not really sure where to start. Try going
through the Job board tutorial, as it will give you an idea of how
things work together.

  http://www.zope.org/Members/mukhsein/job_board_howto


If you want something that is easier to follow, with screenshots and
fuller explanations, and you don't mind paying for it, you might want to
look at Beehive's ZClass Tutorial.

 
http://hive.beehive.de/Beehive/www.beehive.de/Zope/ZClassTutorialEnglish_html


Also, take a look at the Zope documentation project.

  http://zdp.zope.org

Furthermore, there's a tutorial that comes packaged with the latest 2.2
beta versions of Zope. You might like to try that, too.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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 comments on ZPatterns

2000-07-09 Thread Steve Alexander

Steve Spicklemire wrote:
 
 I just want to make sure I understand... is the intention that property management
 needs to be done on each instance separately? So if I add a new property to one
 of my property sheets, I need to somehow update the propertysheets of each of the
 instances? Also if I need to create propertysheets for each instance... where
 should that be done? I suppose it makes sense to put that in the Specialist that
 handles the object that gets the properties?...no?

No need for all that.

Your instances are DataSkins, and they get their PropertySheets via an
InjectionFolder.

All you need to do is tell a DataManager that is in an appropriate
InjectionFolder that it should handle DataSkins of whatever meta_type
your instances have. Furthermore, configure this DataManager to provide
the PropertySheets you want, with sensible default values, and suddenly,
all your instances suport this propertysheet.

An "appropriate InjectionFolder" is one that lies in the acquisition
path of your instances.

[postscript: I only realized this stuff a couple of days ago, when I
started using ZPatterns on a project :-) ]

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] error adding specialist

2000-07-11 Thread Steve Alexander

I've come across an error on trying to add a Specialist.

Zope 2.2b4, ZPatterns latest release (ZPatterns-0-4-0a1).

Go to the zope management pages, as a Manager.
Choose to add a Specialist.
Leave the "Create Default Rack of type" drop-down set to "Rack".
Put in an appropiate id, such as "test".
Press "Add".

We get a Zope error:

  Error Type: TypeError
  Error Value: keyword parameter redefined


Traceback (innermost last):
  File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line
222, in publish_module
  File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line
187, in publish
  File /usr/local/zope/SiteBox/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
  File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line
171, in publish
  File /usr/local/zope/SiteBox/lib/python/ZPublisher/mapply.py, line
160, in mapply
(Object: manage_addSpecialist)
  File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line
112, in call_object
(Object: manage_addSpecialist)
  File
/usr/local/zope/SiteBox/lib/python/Products/ZPatterns/Specialists.py,
line 71, in manage_addSpecialist
  File /usr/local/zope/SiteBox/lib/python/Products/ZPatterns/PlugIns.py,
line 436, in _constructPlugIn
TypeError: (see above)



The error occurs because the _constructPlugIn() method of PlugIns.py
attempts to give "id" to manage_addRack as a keyword argument, whereas
it has already been given the id as a positional argument. Actually, I
think what it is being given as an id is wrong too :-)

The offending line is 436:
  
  return apply(getattr(product, method), (product,)+args, kwargs)



The rest of this is mainly for my benefit, and will be obvious to anyone
familiar with the code :-)


"getattr(product, method)" evaluates to the python method
manage_addRack, and it appears to be a bound method.

"product" is a __FactoryDispatcher__ instance.

"args" is None, or ().

"kwargs" is {'id': 'defaultRack'}.

The signature of manage_addRack() is:

  def manage_addRack(self, id, title='', REQUEST=None):

and is effectively getting called as:

  instance.manage_addRack(some __FactoryDispatcher__, id='defaultRack')

I'm not sure whether the method intended to get an unbound method rather
than a bound one, or whether "id" needs special handling here.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Re: error adding specialist

2000-07-11 Thread Steve Alexander

"Phillip J. Eby" wrote:
 
 I found this one on Saturday.  The problem is that Zope recently changed
 the way constructors bind to their factory objects, and the "self" that
 ZPatterns is providing to the constructors is no longer needed.  I've
 changed ZPatterns to fix this (still maintaining 2.1.x compatibility in the
 process) and a few other reported and unreported bugs, but haven't had time
 to issue a new release just yet.  I'm up to my neck in "regular job" work
 for the next few days. 

My quick "2.2 only" fix is to change line 436 of PlugIns.py to this:

   return apply(getattr(product, method), args, kwargs)


 Hopefully I'll have a release out before the ZPatterns chat Friday, though.

Great. 

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Designing with ZPatterns

2000-07-11 Thread Steve Alexander

Quick question on designing with ZPatterns:

Is a developer meant to specialise Specialist by defining a subclass, as
is the case in LoginManager?

Or, given how many plugpoints Specialist has, is it best to instantiate
Specialists as-is, and fill them with DTML methods, External methods and
triggers and so forth. Then, when you want a new one, it gets
constructed by some sort of wizard.

Or, is the answer "whichever seems most appropriate" ?


Thanks.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] ZPatterns -- trigger add events not working

2000-07-11 Thread Steve Alexander

I have a GenericTrigger in a Folder with Customizer support.

When I set it to trigger upon Add, my method doesn't get triggered when
I add a new DataSkin-derived-ZClass instance. However, when I set it to
trigger on Change, my method gets called on adding a new DataSkin.

I can't see anything obviously amiss in the ZPatterns code.


I've inserted print statements into the _objectChanging() and
_objectAdding() methods of DataManagers.DataManager. It seems that when
I add a DataSkin-derived-ZClass, it gets added and also changed set in a
single transaction, and only one of them gets reported to the trigger.

Strangely, the call to _objectChanging() comes before the call to
_objectAdding().

Is this a bug, or is it the expected behaviour?

Thanks.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] ZPatterns -- trigger add events not working

2000-07-12 Thread Steve Alexander

Steve Alexander wrote:
 
 You could have a flag in DataSkin instances called _has_been_added. It
 is initially cleared. It gets set when manage_afterAdd is called on it.
 
 The DataSkin sends an _objectChanging event only if the _has_been_added
 flag is set.

Of course, the name of the attribute should be more like
_v_has_been_added :-)

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] External Method Missery

2000-07-12 Thread Steve Alexander

Chris Withers wrote:
 
 I think this is a bgu so I'll chuck it into the collector unless someone
 tells me otherwise...
 
 I have an external method called navTree (dtml-tree was too broken to
 fix in the time frame :( ) with a spec as follows:
 
 def navTree(self,start):
 
 It's called in some DTML as:
 
 dtml-var "nav_tree(PARENTS[-2])"
 
 which is fine, unless I call it with the following:
 
 dtml-var "nav_tree(start=PARENTS[-2])"
 
 in which case I get:
 TypeError: not enough arguments; expected 2, got 0
 
 which is not very helpful :(
 
 Any ideas?

Ok.

I debugged this by creating an external method to see what it is
actually receiving:

  def navtree(*arg, **kw):
print 'navtree'
print 'arg= ', arg
print 'kw=  ', kw
print


For  dtml-var "navtree(PARENTS[-1])" we get:
navtree
 arg=  (Application instance at 858ac40,)
 kw=   {}

For dtml-var "navtree(start=PARENTS[-1])" we get:
navtree
 arg=  ()
 kw=   {'start': Application instance at 858ac40}

That is, no "self" argument is getting passed.

Now, I change the external method to have a "self" argument first:

  def navtree(self, *arg, **kw):
print 'navtree'
print 'self=', self
print 'arg= ', arg
print 'kw=  ', kw
print


For  dtml-var "navtree(PARENTS[-1])" we get:
 navtree
 self= Application instance at 858ac40
 arg=  ()
 kw=   {}

For dtml-var "navtree(start=PARENTS[-1])" we get:
 navtree
 self= Folder instance at 8589ea0
 arg=  ()
 kw=   {'start': Application instance at 858ac40}

So, in the first case, you're not getting the current context passed in,
but you are getting it in the second case.


One more try:

  def navtree(self, **kw):
print 'navtree'
print 'self=', self
print 'kw=  ', kw
print

For dtml-var "navtree(PARENTS[-1])" we get:
 navtree
 self= Application instance at 858ac40
 kw=   {}

For dtml-var "navtree(start=PARENTS[-1])" we get:
 navtree
 self= Folder instance at 8589ea0
 kw=   {'start': Application instance at 858ac40}


Looks like it is assumed that the first non-keyword argument should be
passed as the client (ie "self"). 



So, you can fix your exception by giving "start" a default value:

  def navTree(self,start=''):

However, you'll have to always use the keyword form of calling it:

  dtml-var "nav_tree(start=PARENTS[-2])"

Or otherwise, provide a client for it:

  dtml-var "nav_tree(this(), PARENTS[-2])"


As for why this is the case... I have other things to do this morning,
so I won't go rooting around in the DTML source just now. [ Although, it
sure is tempting :-) ]

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Re: Another mystery for you ;-)

2000-07-12 Thread Steve Alexander

Chris Withers wrote:
 
 I was trying to use 'if o in REQUEST.PARENTS' to expand branches on the
 way to the currently displayed object and was running into trouble which
 lead me to try out the following code:
 
 `REQUEST.PARENTS[0]`+`o`+`o==REQUEST.PARENTS[0]`+`o is
 REQUEST.PARENTS[0]`
 
 Now, this renders the following in the case where the branch _should_
 expand:
 Folder instance at 88cbb30Folder instance at 88cbb3000
 
 What I don't understand is how two objects, apparently at the same
 memory location, return false from both 'object1==object2' and 'object1
 is object2'.

Smells like an Acquisition Wrapper misunderstanding :-)

 
http://www.zope.org/Members/michel/Projects/Interfaces/AcquisitionWrappedObject


Use the aq_self or aq_parent attribute to do your comparisons to get
your object out of its magic acquisition wrapper.


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] External Method Missery

2000-07-12 Thread Steve Alexander

Chris Withers wrote:
 
 Shane Hathaway wrote:
  that last algorithm falls to pieces.  The solution is to always provide
  the "self" argument.
 
 When calling or in the signature of your external method?

Both.

Declare it like this:

  def external_method(self, ...other args...):

Use it like this:
 
 dtml-var "external_method(this(),...other args..." ?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Re: ZPatterns: Errors in triggered methods + patch

2000-07-12 Thread Steve Alexander

Steve Alexander wrote:
 
 Latest ZPatterns release. Zope 2.2b4.
 
 If I raise an error in an external method that is called by a
 GenericTrigger, I sometimes get a strange log message:

various bits snipped

 I've put the call to each Agent's "change observed" event in a
 try-except block. This makes my Zope instance happier when I do stupid
 things in external methods, and has the additional advantage of
 insulating other Agents from one particular Agent's problems.

Of course, a patch that made a suitable log entry would be better than
what I just posted to the list, which just writes the execption and
traceback to stderr.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Beginning Zope User

2000-07-13 Thread Steve Alexander

Hi John,

John Gunnar Carlsson wrote:
 
 Help!  I downloaded a product and uploaded it to my directory, but I don't
 know how to unzip it.  I'm using NT.  Whenever I load WinZip it will only
 let me unzip it to local places on the hard disk but nowhere on the Zope
 directory itself.
 
 ___
 Zope-Dev maillist  -  [EMAIL PROTECTED]


I'd really like to help you with this, but there's two reasons that I
can't right now.

1: You've posted this message to the [EMAIL PROTECTED] mailing list.
This list is for discussion about developing the innards of Zope and
really technical stuff like that.
The correct mailing list for your question is the more general
[EMAIL PROTECTED]

2: I'm not sure what you're asking.

When you ask again in [EMAIL PROTECTED], be sure to say all of the
following:

* Exactly which version of Zope you have installed

* Where on your harddisk you have installed it

* What the product is you have downloaded

* Exactly the steps you have tried to follow to install the software

* What documentation you are getting your steps from, and where you got
that documentation from

This might all sound like a lot, but it really is the minimum I'd need
in order to be able to answer your question correctly. Also, if you ask
on [EMAIL PROTECTED], others who might have a similar problem will benefit
from any answer.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] ZPatterns: missing docstring in getItem()

2000-07-13 Thread Steve Alexander

"Phillip J. Eby" wrote:
 
 Changes checked in.  I should be releasing an alpha5 tomorrow.

That's great. Did you get my message about errors in triggered methods?
I realised that I only sent it to the zope-dev list, and not cc-ed to
you.

 I had hoped to finish my work on proxy roles, ZClass plugins, 

Does that increase the number of "Waaa!" comments in the code?

 and maybe even my local-roles stuff first and make it a "beta" release, 

*If* you get time, can you put a note on the ZPatterns Wiki, or to the
zope-dev mailing list briefly describing what proxy roles, and local
roles mean in the context of ZPatterns? Thanks.

(Of course, if any other ZPatterns gurus can answer that...)

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] ZPatterns: BTree folder w/ customizer support

2000-07-13 Thread Steve Alexander

Steve Alexander wrote:
 
 I want to combine Shane Hathaway's BTreeFolder product with ZPatterns to
 create a "BTree folder w/ Customizer support".

snip!
 
 Instead, why not make PlugInContainer a mix-in class, and have concrete
 classes for PlugInFolder and PlugInBTreeFolder ?
 
 Then, it is easy to have a CustomizerFolder and a CustomizerBTreeFolder.
 
 Then again, I wouldn't mind if things stay as they are, except that
 PlugInContainer is made to derive from BTreeFolder rather than Folder.
 Of course, that creates a dependency that you need the BTreeFolder
 product in order to use ZPatterns.

Or... I could alter Shane's BTree Folder product to split it into a
mix-in class and a usable folder class. Would that work, I wonder?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] ZPatterns: missing docstring in getItem()

2000-07-13 Thread Steve Alexander

"Phillip J. Eby" wrote:
 
 That's great. Did you get my message about errors in triggered methods?
 
 Yes, I did, but the solution requires some more thought.  I had thought I
 had the "Transactional" machinery set up so that stuff was only called
 during transaction phases where it was safe to throw errors.  So I'm going
 to have to go back and review that.  However, I also think that errors in
 triggers should result in a rollback-and-abort, rather than silently
 failing, which could cause many other problems.

Right. So the application designer has the choice of whether to put
their methods that are called by GenericTriggers in try-except blocks,
if it doesn't matter if the trigger fails. But it is generally assumed
that triggers need to run without exceptions for the application to work
consistently.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Making Folders callable

2000-07-14 Thread Steve Alexander

Is there any reason that Folders aren't callable?

That is, you can't directly render a folder with dtml-var
nameofafolder. You have to do something like dtml-var
"nameofafolder.index_html(_.None, _)". But, that's not quite the same
because if the folder lacks an index_html, it gets acquired.

Here's an extra method that can be added to lib/python/OFS/Folder.py, or
to ObjectManager.py, to make Folders render nicely.

# XXX hack to make folders render
# retains compatibility with current behaviour
# if the folder doesn't contain index_html
def __call__(self, *args, **kw):
""" mandatory docstring """
index = self._getOb('index_html', default=None)
if index is not None:
args = (self,) + tuple(args[1:])
return apply(index, args, kw)
return ''

Is this a good idea? Should this go into the Collector as an RFE with
patch?

Actually, I'm not sure why it should be tuple(args[1:]) -- I just copied
that out of ZCallable in the latest PTK CVS. I'd guess you'd want to
check the first argument (client) for whether it is None before
replacing it with self.

Perhaps something like this:

  args = (len(args)0 and args[0] or self,) + tuple(args[1:])

Discussion welcomed.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Optimization and speed

2000-07-15 Thread Steve Alexander

Stephan Richter wrote:
 
 snip Method doc string
 
 Looks like it's more that just a tweak, though :-(
 
 So, how can I use this method? I do not understand the internals of the
 ZServer completely.

You've got a RESPONSE object. For HTTP stuff, it will be a HTTPResponse
as defined in lib/python/ZPublisher/HTTPResponse.py.

You can use the write(self, data) method of this response object to
stream data directly to your client, independent (to a degree) of Zope's
transaction processing.

This is the method from HTTPResponse.

def write(self,data):
"""\
Return data as a stream

HTML data may be returned using a stream-oriented interface.
This allows the browser to display partial results while
computation of a response to proceed.

The published object should first set any output headers or
cookies on the response object.

Note that published objects must not generate any errors
after beginning stream-oriented output. 

"""
if not self._wrote:
self.outputBody()
self._wrote=1
self.stdout.flush()

self.stdout.write(data)

So, you could set output headers and cookies as needed, then, before the
rest of the processing on your page, have a dtml-call
"RESPONSE.write('the top of the page')".

Then again, I've never tried this. YMMV and all that.

(*off to help cook... won't be reading email for a while*)

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] ZPatterns: Coad Object Models

2000-07-17 Thread Steve Alexander

Hi Folks, 

After the ZPatterns chat on Friday, it looked like a few people were
thinking of getting into Peter Coad's book "Object Models: Strategies,
patterns and applications".

I've just received my copy, and I'll be starting it later today.


I intend to use a Wiki to record my observations and thoughts about the
book, as I read it. I'd like this to be a collaborative learning thing,
so anyone else who is reading the book, or who as read it, is most
welcome to join in.

  http://www.zope.org/Members/stevea/CoadObjectModels

There's not much up there right now, as I've only read the
Acknowledgements at the front :-)

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Redirecting from the manage interfaces.

2000-07-19 Thread Steve Alexander

Chris Withers wrote:
 
 Why I'm asking is 'cos it'd be really nice not to have to keep
 re-writing UI when there's perfectly good stuff available in the
 management interface, things like add forms, edit forms, etc...
 
 However, if you call these from anywhere else, they dump you in the
 management interface when you're finished rather than going to where you
 want them to.
 
 Any ideas or am I missing the point?

Silly idea: Write a wrapper that you put around the RESPONSE object that
does its own thing when it is told to redirect. You might have to wrap
the REQUEST object too, so that it returns a wrapped RESPONSE object.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] getting request variables values

2000-07-20 Thread Steve Alexander

Leonardo Kenji Shikida wrote:
 
 here it is.

Try using dtml-var "REQUEST['SSLL_CLIENT_IEMAIL']" instead.


 Kenji
 
 
 SSL_CLIENT_IEMAIL [EMAIL PROTECTED]

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] getting request variables values

2000-07-21 Thread Steve Alexander

Chris Withers wrote:
 
 Evan Simpson wrote:
  The value you're after is stored in the 'environ' section of the request.
  Unlike 'other' and 'cookies' keys, 'environ' keys can't generally be fetched
  as attributes or keys of REQUEST.  You need to access them as
  REQUEST.environ['keyname'].
 
 Heh, I thought so, I presume REQUEST.get won't get out of environ
 either?
 
 I posted this in the collector and was told it behaved as expected (and
 would suck the key out of any of the sub-dictionaries)
 
 What's the real story? ;-)

I'm looking at 2.2.0final.

From the comments in the code, it *ought* to look in the environment
first.

  def __getitem__/__getattr__ from HTTPRequest.py:

"""Get a variable value

Return a value for the required variable name.
The value will be looked up from one of the request data
categories. The search order is environment variables,
other variables, form data, and then cookies. 

"""

However, looking in the code, it starts off by looking in "other", and
doesn't look in "environ" at all.

I suggest a patch to go right after the method's docstring:

def __getitem__(self,key,
default=_marker, # Any special internal marker will
do
URLmatch=regex.compile('URL[0-9]+$').match,
BASEmatch=regex.compile('BASE[0-9]+$').match,
):
"""Get a variable value

Return a value for the required variable name.
The value will be looked up from one of the request data
categories. The search order is environment variables,
other variables, form data, and then cookies. 

""" #"
+   environ=self.environ
+   if environ.has_key(key):
+   return environ[key]
other=self.other
if other.has_key(key):
if key=='REQUEST': return self
return other[key]


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] getting request variables values

2000-07-21 Thread Steve Alexander

Steve Alexander wrote:
 
 However, looking in the code, it starts off by looking in "other", and
 doesn't look in "environ" at all.
 
 I suggest a patch to go right after the method's docstring:
 
 def __getitem__(self,key,
 default=_marker, # Any special internal marker will
 do
 URLmatch=regex.compile('URL[0-9]+$').match,
 BASEmatch=regex.compile('BASE[0-9]+$').match,
 ):
 """Get a variable value
 
 Return a value for the required variable name.
 The value will be looked up from one of the request data
 categories. The search order is environment variables,
 other variables, form data, and then cookies.
 
 """ #"
 +   environ=self.environ
 +   if environ.has_key(key):
 +   return environ[key]
 other=self.other
 if other.has_key(key):
 if key=='REQUEST': return self
 return other[key]


Ok... I was wrong :-/

A bit later we have:

if isCGI_NAME(key) or key[:5] == 'HTTP_':
environ=self.environ
if environ.has_key(key) and (not hide_key(key)):
return environ[key]
return ''

I was only sort-of wrong though :-)

The code certainly doesn't stick exactly to its docstring. The "other"
dictionary is seached first, then URLx where x is a number.
Then "environ" is searched, but *only* if the key begins with 'HTTP_' or
is in the following list:

SERVER_SOFTWARE, SERVER_NAME, GATEWAY_INTERFACE, SERVER_PROTOCOL,
SERVER_PORT, REQUEST_METHOD, PATH_INFO, PATH_TRANSLATED, SCRIPT_NAME,
QUERY_STRING, REMOTE_HOST, REMOTE_ADDR, AUTH_TYPE, REMOTE_USER,
REMOTE_IDENT, CONTENT_TYPE, CONTENT_LENGTH, SERVER_URL

Looking in Leonardo's sample environment, a posted to this list, there's
a lot of keys that won't get matched:

SSL_*
HTTPS_*
REMOTE_PORT
SERVER_ROOT
SERVER_SIGNATURE


My question is "why was __getitem__ of HTTPRequest.py designed this
way?".

Is there a good reason that it filters the keys according to membership
of a standard-cgi-keys list, or whether they start with 'HTTP_' ?
Would there be any disadvantage to altering __getitem__ so that it
behaves according to its docstring?

If so, the patch would probably be something like:

line 753.
 """ #"
 +   environ=self.environ
 +   if environ.has_key(key) and (not hide_key(key)):
 +   return environ[key]
 other=self.other
 if other.has_key(key):
 if key=='REQUEST': return self
 return other[key]

if key[:1]=='U' and URLmatch(key) = 0:
path = self._script + self._steps
n = len(path) - atoi(key[3:])
if n  0:
raise KeyError, key
URL=join([other['SERVER_URL']] + path[:n], '/')
other[key]=URL
self._urls = self._urls + (key,)
return URL

-   if isCGI_NAME(key) or key[:5] == 'HTTP_':
-   environ=self.environ
-   if environ.has_key(key) and (not hide_key(key)):
-   return environ[key]
-   return ''

Comments?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] getting request variables values

2000-07-21 Thread Steve Alexander

Steve Alexander wrote:
 
 My question is "why was __getitem__ of HTTPRequest.py designed this
 way?".
 
 Is there a good reason that it filters the keys according to membership
 of a standard-cgi-keys list, or whether they start with 'HTTP_' ?
 Would there be any disadvantage to altering __getitem__ so that it
 behaves according to its docstring?

...although the class docstring says that the environment variable names
are as in the CGI specification
(http://hoohoo.ncsa.uiuc.edu/cgi/env.html). It doesn't say that they
should **only** be from the CGI specification, though.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] DateTime.py

2000-07-23 Thread Steve Alexander

There's a problem with strftime() in DateTime.py.

Try this DTML method to see:


dtml-var standard_html_header
dtml-let time1="_.DateTime('2000/07/23 BST')"
  Time: dtml-var time1 br
  Time: dtml-var time1 fmt=Date br
  Time: dtml-var time1 fmt="DayOfWeek" br
  Bad Time: dtml-var time1 fmt="%a, %d %B %Y %Z" br
  Time: dtml-var "time1.fCommonZ()" br
/dtml-let

dtml-let time1="_.DateTime('2000/07/23 GMT')"
  Time: dtml-var time1 br
  Time: dtml-var time1 fmt=Date br
  Time: dtml-var time1 fmt="DayOfWeek" br
  Time: dtml-var time1 fmt="%a, %d %B %Y %Z" br
  Time: dtml-var "time1.fCommonZ()" br
/dtml-let

dtml-var standard_html_footer


Note that the time given in the line "Bad Time:" above is actually wrong
-- it reports itself to be in GMT, but gives the time as one hour
behind.

If you specify a date as /MM/DD, then the date that is stored is
(quite reasonably) midnight on that day, in your timezone.

This gets rendered back into days correctly for methods such as
DateTime.day(), as these methods directly ask the DateTime instance for
what it thinks the day is. The instance replies in the context of its
own timezone (as given in the constructor, or the local timezone if none
was given), and so it returns the expected result.

If you use the strftime() method, by using fmt="%d %H %Z" or whatever,
instead of asking the DateTime instance to do the formatting, the
formatting is delegated to the Python time module.

Unfortunately, at any particular time, the Python "time" module only
knows about two timezones: Your local one (with and without daylight
savings) and GMT.

Therefore, in any other timezones, Pythons time.strftime() cannot
correctly render the time.

This is particularly apparent in the current DateTime.py, because its
strftime method just interprets the internal representation of the time
as GMT, whatever.

We can fix this easily:

*** lib/python/DateTime/DateTime.py Sun Jul 23 20:03:05 2000
--- lib/python/DateTime/DateTime.old.py Sun Jul 23 20:03:04 2000
***
*** 1376,1382 
  return millis
  
  def strftime(self, format):
! return strftime(format, gmtime(self.toZone('GMT').timeTime()))
  
  # General formats from previous DateTime
  def Date(self):
--- 1376,1382 
  return millis
  
  def strftime(self, format):
! return strftime(format, gmtime(self.timeTime()))
  
  # General formats from previous DateTime
  def Date(self):


Now, at least, the time will be reported correctly, although not really
usefully if you want to have the time formatted in the timezone given to
the DateTime instance.

Also, this patch will cause formatting calls to create a new DateTime
instance if the instance you want to format is not in timezone GMT+0. 

The only general solution that I can see is to replicate the formatting
algorithms of the time module in DateTime.py, but written so that they
take account of timezones.


There is another issue:

When I call _.DateTime('2000-07-23'), what do I mean? 

The current implementation of DateTime interprets that as "midnight (the
earliest possible time) on 2000-07-23, interpreted in the local
timezone".

However, if I'm being naive, I might think that I'm refering to a Day,
and that the Day should be the same day no matter what timezone I put it
into.

In that case, the DateTime module needs rewriting to have a sense of
precision built into it: If I specify a time to the day, I get the
latter behaviour. If I specify the time more precisely, I get the
current behaviour.

Another approach would be to make _.DateTime('2000-07-23') mean Midday,
GMT rather than Midnight, local time. That would give the latter
behaviour for most timezones at most times; the exceptions being places
near the international date line that are in daylight savings time.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] DateTime.py -- ignore the patch

2000-07-23 Thread Steve Alexander

Steve Alexander wrote:
 
 This is particularly apparent in the current DateTime.py, because its
 strftime method just interprets the internal representation of the time
 as GMT, whatever.
 
 We can fix this easily:
 
 *** lib/python/DateTime/DateTime.py Sun Jul 23 20:03:05 2000
 --- lib/python/DateTime/DateTime.old.py Sun Jul 23 20:03:04 2000
 ***
 *** 1376,1382 
   return millis
 
   def strftime(self, format):
 ! return strftime(format, gmtime(self.toZone('GMT').timeTime()))
 
   # General formats from previous DateTime
   def Date(self):
 --- 1376,1382 
   return millis
 
   def strftime(self, format):
 ! return strftime(format, gmtime(self.timeTime()))
 
   # General formats from previous DateTime
   def Date(self):
 
 Now, at least, the time will be reported correctly, although not really
 usefully if you want to have the time formatted in the timezone given to
 the DateTime instance.

No, no, no! 

Ignore the patch, it is a placebo :-/  
I should read these things back more carefully...


The bit about reimplementing time.strftime() in DateTime.py still holds
though.
 
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] DateTime.py -- ignore the patch

2000-07-23 Thread Steve Alexander

Steve Alexander wrote:
 
 No, no, no!
 
 Ignore the patch, it is a placebo :-/
 I should read these things back more carefully...
 
 The bit about reimplementing time.strftime() in DateTime.py still holds
 though.

In brief, though -- and hopefuly clearer this time:

If you format DateTimes using strftime (that is, fmt="%d %m" and so
forth), you can only have the time rendered in GMT.

This is confising the counter-intuitive, as the internal timezone of the
DateTime instance is not preserved.

The only reasonable way around this is to reimplement the strftime
function of Python's time module in DateTime.py, but have it take
account of timezones.

As another issue, when you create a new DateTime instance with
_.DateTime('-MM-DD'), the actual time stored is midnight in your
local timezone. A more useful default time would be midday, GMT. This
shouldn't break much code, as the current behaviour isn't well
documented and is arguably broken anyway.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Incorrect Padding?

2000-07-24 Thread Steve Alexander

Chris Withers wrote:
 
 Does anyone know what this means?
 
 The page views fine for me and this is the first error of this type I've
 seen since we launched the archives. I wonder what WebWhacker is doing
 to cause this?

Well... you can get an incorect padding error like this:

 import binascii
 binascii.a2b_base64('a ') 

Traceback (innermost last):
  File "stdin", line 1, in ?
binascii.Error: Incorrect padding

You can also get by adding arbitrary non-space characters to the end of
a basic authentication string.

Here's the line that'll be causing the problem.

(Zope 2.2final, lib/python/AccessControl/User.py line 441)

  name,password=tuple(split(decodestring(split(auth)[-1]), ':', 1))

My guess is that the argument "auth" passed to validate() has some
trailing characters. Either that, or WebWhacker passed just "Basic " as
an auth string.

Maybe log the auth argument and re-whack your site. (Warning... this is
certainly a nasty security hole. Be sure to get rid of the logging
afterwards.)

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

___
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] Incorrect Padding?

2000-07-24 Thread Steve Alexander

Chris Withers wrote:
 
 Steve Alexander wrote:
  My guess is that the argument "auth" passed to validate() has some
  trailing characters. Either that, or WebWhacker passed just "Basic " as
  an auth string.
 
 Yuk, that sounds like a Zope bug. Collector time with patch? A judicious
 string.strip should solve the problem, surely?

 from base64 import decodestring
 from string import *
 auth="Basic"
 tuple(split(decodestring(split(auth)[-1]), ':', 1))
Traceback (innermost last):
  File "stdin", line 1, in ?
  File "/usr//lib/python1.5/base64.py", line 46, in decodestring
decode(f, g)
  File "/usr//lib/python1.5/base64.py", line 32, in decode
s = binascii.a2b_base64(line)
binascii.Error: Incorrect padding

The problem is in the expression "split(auth)[-1]". If the auth string
contains no space but at least one character, then split(auth)[-1] ==
split(auth)[0].

Perhaps what we should do is change this
(lib/python/AccessControl/User.py, line 438)

# Only do basic authentication
if lower(auth[:6])!='basic ':
return None
name,password=tuple(split(decodestring(split(auth)[-1]), ':',
1))

to this:

# Only do basic authentication
if lower(auth[:6])!='basic ' and len(auth)6:
return None
name,password=tuple(split(decodestring(split(auth)[-1]), ':',
1))

or even:

# Only do basic authentication
if lower(auth[:6])!='basic ':
return None
name,password=tuple(split(decodestring(auth[6:]), ':', 1))

(Need to check the last one with the RFC -- are you allowed anything
else other than "basic blarglebase64usernamepassword" ? )


  Maybe log the auth argument and re-whack your site. (Warning... this is
  certainly a nasty security hole. Be sure to get rid of the logging
  afterwards.)
 
 I didn't whack my site, I just got mailed the error...

Well... try whacking yourself and see what the whacker actually sends --
we're just guessing until then.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

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




  1   2   3   4   5   >