[Zope] errors in sql method

2000-07-18 Thread Tim Hicks



SELECT *
FROM 
WHERE "Play title" like ;

Can anybody explain to me what is going on with my zsql method?  Zope
gives me the following error when I try and change my method to what
is above.

Invalid attribute name, "which_table", for tag , on line 16 of 

I've scoured the mailing list, but I'm still mightily confused.
which_table is one of the arguments for the the sql method and Plays
is a string that I want to compare it with.  which_table comes from a
form elsewhere.  I'm sure it's something really simple, and I'm sure
it's been discussed here before (at length?), but ATM, I don't even
know what I'm looking for!

Thanks for the help

tim


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




Re: [Zope] errors in sql method

2000-07-18 Thread Tim Hicks

- Original Message -
From: "Gregory Haley" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Sent: Tuesday, July 18, 2000 7:35 PM
Subject: Re: [Zope]  errors in sql method


> Hi,
>
> Are you searching for the exact word "Plays", or is there a
> variable called Plays against which you are trying to match
> a value?  If it's the latter, having the single quotes is
> teling it to search for the literal.  If you are setting the
> value of plays in a higher call, eg.  "REQUEST.set('Plays', Play_titles)">, your if expression
> would need to be "which_table == Plays".
>
> Hope this is helpful, as it is a mistake I am always making!
>
> ciao!
> greg.
>
> Gregory Haley
> venaca.com
>

Thanks for that... I am trying to compare which_table to the exact
string Plays.  Plays is not a variable/argument/integer//whatever,
I am just trying to see if the string that is returned from one of the
fields of my form (which_table) is equal to the string Plays.



Tim:  [EMAIL PROTECTED]





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




Re: [Zope] errors in sql method

2000-07-18 Thread Tim Hicks

- Original Message -
From: "Dieter Maurer" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Sent: Tuesday, July 18, 2000 9:51 PM
Subject: Re: [Zope]  errors in sql method


> Tim Hicks writes:
>  > 
>  >
>  > SELECT *
>  > FROM 
>  > WHERE "Play title" like   > "'%'+_.string.strip(form_string)+'%'" type=string>;
>  >
>  > Can anybody explain to me what is going on with my zsql method?
Zope
>  > gives me the following error when I try and change my method to
what
>  > is above.
>  >
>  > Invalid attribute name, "which_table", for tag   > == 'Plays'">, on line 16 of 
> The error message looks strange.
> It seems that the parser does not see the "...", because
"which_table"
> actually is not an attribute at all.
>
> Did you declare "which_table" as argument of the Z SQL method.
> This will probably not remove your current problem but
> may later come up.
>
>
> Dieter
>

Yes, which_table and form_string are both declared as arguments in the
zsql method.

Tim:  [EMAIL PROTECTED]




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




[Zope] How to get URL of folder (name unknown) with a certain property?

2000-08-27 Thread Tim Hicks

I am trying to figure out how to get hold of the URL (using
absolute_url I presume) of a folder with a property called
"sehs_root_folder" set to "yes".  I do not know what the name of this
folder is, so I am finding it difficult to use the hasattr function,
and I don't have any way of knowing where abouts in the document tree
the folder is (except that it must be a 'parent' folder of the one
that contains the dtml-method that I am running the code from).

Does that make any sense?  I'm finding it difficult to even express my
question, so searching the mailing list archives is proving fruitless.

I'd appreciate any pointers

tim

ps.  The reason I'm trying to do this is to make my site more
portable.  I would like to be able to change servers and/or folder
names on my server without damaging all the links and addresses to
images/files on the site.  As such, everywhere that I have any sort of
link/address on the site, I currently use the following:

/address/to/whatever/

 is a method that resides in the 'root' folder of the
site, and in it, I put the current appropriate path for the site.
However, I would like to make this method automatically figure out the
appropriate path.  Therefore, I gave the 'root folder' a property
called "sehs_root_folder" that I hope to search for.  If you have a
more efficient way of solving my problem, please let me know.


Tim:  [EMAIL PROTECTED]


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




[Zope] Nested dtml???

2000-08-28 Thread Tim Hicks

I am trying to work my way up through folders, checking whether each
folder has a property named 'site_root_folder'.  Logically (in *my*
head anyway), what I have written below is what I want to do, but I'm
not sure that I'm really writing this the write way.  I vaguely
remember reading that I can't nest dtml-if tags within dtml-in tags.

I'd really appreciate any help on this

tim










Tim:  [EMAIL PROTECTED]




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




Re: [Zope] Nested dtml???

2000-08-29 Thread Tim Hicks

- Original Message -
From: "Dieter Maurer" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: "zope" <[EMAIL PROTECTED]>
Sent: Tuesday, August 29, 2000 11:10 PM
Subject: Re: [Zope] Nested dtml???


> Tim Hicks writes:
>  > I am trying to work my way up through folders, checking whether
each
>  > folder has a property named 'site_root_folder'.  Logically (in
*my*
>  > head anyway), what I have written below is what I want to do, but
I'm
>  > not sure that I'm really writing this the write way.  I vaguely
>  > remember reading that I can't nest dtml-if tags within dtml-in
tags.
> There is no problem whatsoever to use "dtml-if" inside "dtml-in".
>
>  > 
>  > 
>  > 
>  > 
>  > 
>  > 
>  > 
> "dtml-in" works with sequences.
>
> In your example, however, you give it an integer ("level").
> It will not be happy with this.
>
> You may try:
>
> 
>   
> 
> 
>

Excellent.  Here is what I have managed to make work.







I really appreciate it.  And thanks for the reply on my other
(related) post.  Don't think I'll mess with ZopeFind for now; I don't
always have access to Zope 2.2.x, but more usually 2.1.6.

Thanks again.

tim


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




Re: [Zope] Nested dtml???

2000-08-29 Thread Tim Hicks

- Original Message -
From: "Curtis Maloney" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>; "zope" <[EMAIL PROTECTED]>
Sent: Wednesday, August 30, 2000 12:24 AM
Subject: Re: [Zope] Nested dtml???


> On Tue, 29 Aug 2000, Tim Hicks wrote:
> > I am trying to work my way up through folders, checking whether
each
> > folder has a property named 'site_root_folder'.  Logically (in
*my*
> > head anyway), what I have written below is what I want to do, but
I'm
> > not sure that I'm really writing this the write way.  I vaguely
> > remember reading that I can't nest dtml-if tags within dtml-in
tags.
> >
> > I'd really appreciate any help on this
> >
> > tim
> >
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >
> >
> Hmm.. it may be slower, but I would normally use a recursive
function in this
> case.
>
> DTML Method  findRoot
>
> 
>   
> 
>   
> 
>
>
> Use as:
>
> 
>

Thanks for the ideas, but I have managed to do what I wanted to do
using the code below (with help from Dieter Maurer).







> > Tim:  [EMAIL PROTECTED]
> >
>
> If you don't mind my asking, why do you need to hunt down this
folder?  Is
> there no way Acquisition could be used to simplify your life?
>

I have made a couple of 'sites' that need to be portable so that they
can be placed on any server, with their 'root' directory having any
name without needing to edit anything. Therefore, in every link/URL
within the site, I do something like the following,

href="/link/to/whatever.html"

The path method is what contains the code that I have shown above.  In
this way, all the links work no matter what server they are placed on
(zope of course!).  I don't think I could have just used relative
links as my standard_html_header/footer contains links/images.  With
relative links, when the header/footer was placed into a document that
was not in the site's root folder, they were broken.

Does that make any sense?  Have I gone about it a bit backwards?

Anyway, you did ask :-)

tim


> Have a better one,
> Curtis
>


___
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] and PARENTS[0]

2000-08-31 Thread Tim Hicks

OK, I have a standard_html_header for my site that uses the following


 

 

 













In this way, the properties of the ZClass (into which the
standard_html_header is placed) are used for the for the meta
author/copyright/keywords/description/javascript.  All of those that I
just mentioned work perfectly well, with the correct property being
inserted, however,  results in the id of the parent
folder of standard_html_header being inserted, instead of the id of
the zclass.  Could anyone point out how I can get hold of the zclass
id?

thanks very much

tim


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




Re: [Zope] and PARENTS[0]

2000-08-31 Thread Tim Hicks

- Original Message -
From: "Geir Bfkholt" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, August 31, 2000 2:30 PM
Subject: Re: [Zope]  and PARENTS[0]


> on Thursday, August 31, 2000 Tim Hicks wrote :
> TH> OK, I have a standard_html_header for my site that uses the
following
> [snip]
> TH>with the correct property being
> TH> inserted, however,  results in the id of the parent
> TH> folder of standard_html_header being inserted, instead of the id
of
> TH> the zclass.  Could anyone point out how I can get hold of the
zclass
> TH> id?
>
> first of all :
> make sure your standard_html_header is a method, not a
> document
>

Yup, definitely a method.  Out of interest, if it were a document, why
would all of the  work except id?

tim

> --
> Geir Bækholt
> web-developer/designer
> [EMAIL PROTECTED]
> http://www.funcom.com
>
>
>


___
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: Re[2]: [Zope] and PARENTS[0]

2000-08-31 Thread Tim Hicks


- Original Message -
From: "Geir Bfkholt" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, August 31, 2000 2:56 PM
Subject: Re[2]: [Zope]  and PARENTS[0]


> on Thursday, August 31, 2000 Tim Hicks wrote :
>
> 
> TH> Yup, definitely a method.  Out of interest, if it were a
document, why
> TH> would all of the  work except id?
>
> acquisition, i guess.. satandard_html_header would not
> usually have those properties itself..
>
> if it was a document, and had those other properties, the
> ones from the header would be used..
>
> Seems rather strange that id from standard_html_header is
> used if it is a method.. puzzling..
>
> cannot think of a reason..
>
>

DOH!  There was me thinking that I had to use PARENTS[0] in order to
get hold of the zclas that had standard_html_header inserted into
it... when I don't!  Taken out all the PARENTS[0]'s and it is behaving
like it should do.  Now it's working, I think I actually understand
how it works as well!

Sorry about that, I think I made things more complicated than they
are.

tim


> --
> Geir Bækholt
> web-developer/designer
> [EMAIL PROTECTED]
> http://www.funcom.com
>
>
>


___
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] How to access id and title of document calling standard_html_header

2000-09-02 Thread Tim Hicks

For those of you who saw my posts from a couple of days ago (Dieter
Maurer and Geir Bfkholt), this is the question that I think I should
have been asking in the first place.

I have a standard_html_header that is inserted into Zclasses.  These
Zclasses have properties including meta_author, meta_description etc
(I don't think it is important what they are, just that they are
properties that standard_html_header does not have).  In the
standard_html_header, I use code such as  and
.  This works fine and the properties of
the *zclass* are inserted.  However, if I put  into the
standard_html_header, I get the id of standard_html_header, *not* of
the zclass.  How do I tell zope to which item I am refering (bearing
in mind, I don't know the name of the zclass ie it is variable)?

Cheers

tim

ps. As a workaround, I have simply given my zclasses an alternative
property (counter_id) that I make the same as the real id, but this
seems to be a clumsy way of doing it.


___
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] How to access id and title of document calling standard_html_header

2000-09-02 Thread Tim Hicks

For those of you who saw my posts from a couple of days ago (Dieter
Maurer and Geir Bfkholt), this is the question that I think I should
have been asking in the first place.

I have a standard_html_header that is inserted into Zclasses.  These
Zclasses have properties including meta_author, meta_description etc
(I don't think it is important what they are, just that they are
properties that standard_html_header does not have).  In the
standard_html_header, I use code such as  and
.  This works fine and the properties of
the *zclass* are inserted.  However, if I put  into the
standard_html_header, I get the id of standard_html_header, *not* of
the zclass.  How do I tell zope to which item I am refering (bearing
in mind, I don't know the name of the zclass ie it is variable)?

Cheers

tim

ps. As a workaround, I have simply given my zclasses an alternative
property (counter_id) that I make the same as the real id, but this
seems to be a clumsy way of doing it.



___
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 access id and title of document calling standard_html_header

2000-09-02 Thread Tim Hicks


- Original Message -
From: "Kapil Thangavelu" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, September 02, 2000 3:59 PM
Subject: Re: [Zope] How to access id and title of document calling
standard_html_header


> Tim Hicks wrote:
> >
> > For those of you who saw my posts from a couple of days ago
(Dieter
> > Maurer and Geir Bfkholt), this is the question that I think I
should
> > have been asking in the first place.
> >
> > I have a standard_html_header that is inserted into Zclasses.
These
> > Zclasses have properties including meta_author, meta_description
etc
> > (I don't think it is important what they are, just that they are
> > properties that standard_html_header does not have).  In the
> > standard_html_header, I use code such as 
and
> > .  This works fine and the properties
of
> > the *zclass* are inserted.  However, if I put  into
the
> > standard_html_header, I get the id of standard_html_header, *not*
of
> > the zclass.  How do I tell zope to which item I am refering
(bearing
> > in mind, I don't know the name of the zclass ie it is variable)?
> >
> > Cheers
>
>
> Make your standard_html_header a DTML Method not a Document. Methods
> operate on their containers. Documents operate on themselves. The
> Document is acquiring the ZClass properties after looking through
its
> own. The Method looks for the properties of its containers.
>
> Kapil
>

It is a method already!  Any ideas.  If it makes any difference, I'm
running Zope 2.2.0 (although I really don't think this is important).

tim


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




Re: [Zope] How to access id and title of document calling standard_html_header

2000-09-04 Thread Tim Hicks


- Original Message -
From: "Dieter Maurer" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, September 04, 2000 7:48 PM
Subject: Re: [Zope] How to access id and title of document calling
standard_html_header


> Tim Hicks writes:
>  > I have a standard_html_header that is inserted into Zclasses.
These
>  > Zclasses have properties including meta_author ...
>  > In standard_html_header, I use code such as  ...
>  > This works fine and the properties of
>  > the *zclass* are inserted.  However, if I put  into
the
>  > standard_html_header, I get the id of standard_html_header, *not*
of
>  > the zclass.
> When I do this, I get the id of the Z class instance.
> It should be impossible to get the id of the *standard_html_header*,
> if this header is a DTML *method* (rather than document) as you
> told us in a different message.
>
> Because we see different things, we need to describe carefully,
> what we do. Apparently, we do not do the same.
>
> I have a folder-like ZClass, say ZC, and an instance of this class,
say ZI.
> ZC has a method, say M, using "standard_html_header".
> "standard_html_header" is a DMTL method (!) rendering "id".
> When I open "ZI/M", "standard_html_header" renders "ZI", i.e.
> ZI's id.
>
> The same happens, if "standard_html_header" is not in ZI but
> a ZC method.
>
>
> Now, it is your turn to describe precisely, what you are doing.
>

OK, I think that I am perhaps misusing zclasses then.  Here is what I
have.

I have a Folder that was created by using the 'Add new item' menu
within Zope.  This folder is called 'Site'.

I have a Zclass called 'theatre_class' that has "Base classes ZObject,
_ZClass_for_CatalogAware, _ZClass_for_DTMLDocument".  I have set the
zclass to have the following properties by creating a
'theatre_class_property' property sheet for it:
head_title
meta_author
meta_description
... amongst others.

Within the Folder 'Site', I have standard_html_header dtml-method that
is an edited version of the default one that is found in the root
folder of a Zope instance (if that is the right term).  This
standard_html_header uses things code such as this:




When I use the standard_html_header in an instance of a zclass, the
appropriate property of the zclass is indeed inserted into it.  See
below.

Zclass instance has code such as:



This is an instance of my Theatre Zclass



However, if I try to put  into the standard_html_header,
I get nothing, and if I use , I get
'standard_html_header' inserted into the document.

I hope I have made it clear what I am doing.  It is certainly becoming
clear to me that I have got the wrong end of the stick a little with
this.

Thanks for your help.

tim

>
> Dieter
>


___
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: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header)

2000-09-05 Thread Tim Hicks


- Original Message -
From: "Dieter Maurer" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, September 05, 2000 9:44 PM
Subject: ZClass Bug (was: Re: [Zope] How to access id and title of
document calling standard_html_header)


> Tim Hicks writes:
>  > OK, I think that I am perhaps misusing zclasses then.  Here is
what I
>  > have.
> No you did not.
>

That's a relief.

>  > I have a Folder that was created by using the 'Add new item' menu
>  > within Zope.  This folder is called 'Site'.
>  >
>  > I have a Zclass called 'theatre_class' that has "Base classes
ZObject,
>  > _ZClass_for_CatalogAware, _ZClass_for_DTMLDocument"
>  >
>  > Within the Folder 'Site', I have standard_html_header dtml-method
...
>  > However, if I try to put  into the
standard_html_header,
>  > I get nothing...
>
> I analysed your problem (in Zope 2.1.6).
> It is *NOT* a problem of "standard_html_header".
> Instead, it is a ZCLass problem.
>

OK.

> The id of a ZInstance created as
> you described it returns "". The browser shows this
> as "empty" because it is a tag it does not understand and
> therefore ignores.
> You see it, though, when you look at the HTML source.
>

Yup, I'm with you on that.

> The reason for this strange id lies in a mismatch between
> your ZClass, more precisely its __init__ method, and
> the content of REQUEST:
>For some reason, your ZClass uses
>"DocumentTemplate.DT_String.__init__" as constructor.
>"DocumentTemplate.DT_String" defines a "id" function
>and lets it return the value of the "__init__" parameter
>"__name__". The default for "__name__" is, you guess it,
>"''".
>

You are losing me a bit with the "__init__",
"DocumentTemplate.DT_String" and "__name__" (I'm afraid my Python is
limited, to say the least!).  I do see the results of  being
the default value though ;-).

>"ZClass.createInObjectManager" constructs the ZInstance.
>If the instance has a 'id', it takes this id and
>ignores the 'id' passed as parameter.
>
>Thus, you get a ZInstance with this strange id.
>

I think I'm with you there.

>
> I am convinced, this is a ZClass bug.
> I think, that the bug results from the fact, that
> the constructor for a ZCLass deriving from DTML Document
> used "__name__" as "id" replacement.
>
>
> The analysis provides a workaround for you.
> In your ZClass constructor, add
> 
> before the
> .createInObjectManager(REQUEST['id'],REQUEST)">
>

Great.  I presume that this will only work for all *new* instances of
this class however!  I don't suppose you know of a way of remaking all
44 instances of this Zclass I have using this adjusted constructor? I
have tried (see below), but I think I come up against the same
'' problem that I'm actually trying to counteract!






 
 





Anyway, I guess this is a different problem again really isn't it?  I
think for now, it will be easier to use my less elegant workaround of
giving the zclass another property called 'counter_id' * that is the
same as the actual id.  I know that this works, and it won't take as
long as remaking all the instances again... I don't have the strength
for that I don't think.

I'll definitely file away your fix for future reference though.
Thanks very much.

>
>
> Now, after I did some work for you, I have some tasks for you:
>
>   * check, whether the bug is in Zope 2.2.1, too

Yes, it does.  I have now found this to occur in 2.1.6, 2.2.0 and
2.2.1.

>   * if this turns out to be the case, file a bug report into
> the collector.
>

Right, I have done that, hopefully satisfactorily!  Hope you don't
mind, I used 'extensive' quotes from your reply... no point in using
my words to confuse the issue!
Thanks very much Dieter, you've been a MASSIVE help.

tim

>
> Dieter
>


___
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: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header)

2000-09-06 Thread Tim Hicks


- Original Message -
From: "Dieter Maurer" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, September 05, 2000 9:44 PM
Subject: ZClass Bug (was: Re: [Zope] How to access id and title of
document calling standard_html_header)




>
> The analysis provides a workaround for you.
> In your ZClass constructor, add
> 
> before the
> .createInObjectManager(REQUEST['id'],REQUEST)">
>


Dieter,

I tried using the code that you suggested above, but I get the
following error from Zope 2.2.1



File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_With.py, line
133, in render
(Object: theatre_class.createInObjectManager(REQUEST['id'],
REQUEST))
  File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_Util.py,
line 337, in eval
(Object: theatre_class.createInObjectManager(REQUEST['id'],
REQUEST))
(Info: REQUEST)
  File <string>, line 0, in ?
NameError: theatre_class

It would seem that  is still raising its head.  Any ideas?

tim


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




[Zope] Zclass not reindexing (it is CatalogAware)

2000-09-07 Thread Tim Hicks

I have created a Zclass, the the _ZClass_for_CatalogAware base class
as the first added base class (second in the list of base classes).
My zcatalog (named Catalog) is set to 'Find objects of type:
"myClass_metatype"' and therefore, when I add a new instance of my
class, it is automatically added to the catalog.  By that, I mean that
once I have added the instance, I can go the the 'Cataloged Objects'
view and see it listed there. However, if I try a search using the raw
(TextIndex) search outlined in one of the tutorials, the search fails
to find words that I *know* are in the zclass that I just added, and
that I thought had been cataloged.  Clicking on 'Update Catalog' in
the 'Cataloged Objects' view and then researching means that the
search succeeds in finding the word in the new instance.

The question is, do I need to add the equivalent of what is written in
'How-To: Creating a CatalogAware ZClass' for reindexing zclass
properties, but for reindexing the actual text?  How could I do this?









Help much appreciated,

tim


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




[Zope] Re: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header)

2000-09-07 Thread Tim Hicks


- Original Message -
From: "Dieter Maurer" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Sent: Thursday, September 07, 2000 7:00 PM
Subject: Re: ZClass Bug (was: Re: [Zope] How to access id and title of
document calling standard_html_header)


> Hi Tim
>
>  > NameError: theatre_class
>  >
>  > It would seem that  is still raising its head.  Any
ideas?
> I do not think so.
> You get a name error: Zope does not know your "theatre_class" at
> this point.
>
> It seems more likely, that DC changed to way ZClasses are located
> inside the constructor.
>
> Take the generated ZClass constructor and simply add
> the "...REQUEST.set..." before the "createInObjectManager".
>

OK, I'm so sorry about this, you've been an absolute legend so far,
and I really don't want to push my luck, but each time you solve
something, I find something else that has broken.

This is what my theatre_class_add method looks like (well, an excerpt
anyway).




 
 \n\n', '')">




When I try to create a new instance of the zclass in the original
'site' folder (or any of its parent folders except for the root), I
get this error. I do not receive an error and everything works fine
when I create the instance in a new folder on a different 'branch' to
the original.


Traceback (innermost last):
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 222,
in publish_module
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 187,
in publish
(Object: testing)
  File C:\PROGRA~1\Zope221\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
(Object: RoleManager)
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 171,
in publish
(Object: testing)
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\mapply.py, line 160,
in mapply
(Object: theatre_class_add)
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 112,
in call_object
(Object: theatre_class_add)
  File C:\PROGRA~1\Zope221\lib\python\OFS\DTMLMethod.py, line 172, in
__call__
(Object: theatre_class_add)
  File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_String.py,
line 528, in __call__
(Object: theatre_class_add)
  File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_With.py,
line 133, in render
(Object: theatre_class.createInObjectManager(REQUEST['id'],
REQUEST))
  File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_Util.py,
line 337, in eval
(Object: theatre_class.createInObjectManager(REQUEST['id'],
REQUEST))
(Info: REQUEST)
  File <string>, line 0, in ?
NameError: theatre_class



When I try to copy and paste a zclass from this original 'site' folder
(or any of its parent folders except for the root), I get this error.
I do not receive an error and everything works fine when I copy and
paste an instance in a new folder on a different 'branch' to the
original.

"One or more items referred to in the clipboard data was not found.
The item may have been moved or deleted after you copied it."


When I try to rename a class that is in the original 'site' folder (or
any of its parent folders except for the root), I get this error. I do
not receive an error and everything works fine when I rename an
instance in a new folder on a different 'branch' to the original.


Traceback (innermost last):
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 222,
in publish_module
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 187,
in publish
  File C:\PROGRA~1\Zope221\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
(Object: Traversable)
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 171,
in publish
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\mapply.py, line 160,
in mapply
(Object: manage_renameObjects)
  File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 112,
in call_object
(Object: manage_renameObjects)
  File C:\PROGRA~1\Zope221\lib\python\OFS\CopySupport.py, line 273, in
manage_renameObjects
(Object: Traversable)
  File C:\PROGRA~1\Zope221\lib\python\OFS\CopySupport.py, line 285, in
manage_renameObject
(Object: Traversable)
  File C:\PROGRA~1\Zope221\lib\python\OFS\ObjectManager.py, line 236,
in _getOb
(Object: Traversable)
AttributeError: (see above)


Like I say, you've been fantastic in helping me.  Thanks to you, I now
have a solution whereby I know I can redo all of the class instances I
have created, and be sure that the error won't reappear.  However, I'm
sure from what you have said so far, there is a way around this that
doesn't involve me 'writing off' all the instances that I have already
created.  My problem is, I'm a little out of my depth here!  I don

Re: [Zope] Zclass not reindexing (it is CatalogAware)

2000-09-07 Thread Tim Hicks


- Original Message -
From: "R. David Murray" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, September 07, 2000 10:12 PM
Subject: Re: [Zope] Zclass not reindexing (it is CatalogAware)


> On Thu, 7 Sep 2000, Tim Hicks wrote:
> > The question is, do I need to add the equivalent of what is
written in
> > 'How-To: Creating a CatalogAware ZClass' for reindexing zclass
> > properties, but for reindexing the actual text?  How could I do
this?
>
> When is the text created?  After it is, you have to call
reindex_object.
>

So each time there is a change made to the text, I must call
reindex_object, is that correct?  If so, how do I make it so that each
time I hit the 'Change' button at the bottom of the text box,
 is executed?

cheers

tim
> --RDM
>


___
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] Simple dtml-unless problem

2000-09-13 Thread Tim Hicks


- Original Message -
From: "Oleg Broytmann" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, September 13, 2000 12:56 PM
Subject: Re: [Zope] Simple dtml-unless problem


> On Wed, 13 Sep 2000, Tim Hicks wrote:
> > 
>
>Sometimes id is string, sometimes it is a function.
>
> 
>

Thanks very much guys.  _['id'] fixed it.

tim
> Oleg.
> 
>  Oleg Broytmannhttp://phd.pp.ru/
[EMAIL PROTECTED]
>Programmers don't die, they just GOSUB without RETURN.
>


___
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] Simple dtml-unless problem

2000-09-13 Thread Tim Hicks

I have the following code in my standard_html_header






The problem is, it displays the  and  stuff even when the
page that the standard_html_header is being dropped into is
index_html.  I'm pretty sure I'm missing something really silly here,
but if anyone could point it out, I'd really appreciate it.

cheers

tim


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




[Zope] Re: CASE in point -- [Zope] Simple dtml-unless problem

2000-09-13 Thread Tim Hicks


- Original Message -
From: "albert boulanger" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, September 13, 2000 1:45 PM
Subject: CASE in point -- [Zope] Simple dtml-unless problem


>
>On Wed, 13 Sep 2000, Tim Hicks wrote:
>> 
>
>   Sometimes id is string, sometimes it is a function.
>
>
>
> This is a great example of DTML as a language having a multiple
> personality disorder. This violates a principle of consistent
> syntax/semantics. It wants to fool you that you could in fact do
>  but no. I understand why DTML was
> designed this way, but in attempting to be a very convenient
language
> in syntactic simplicity, it did not do it to completion and there
are
> these traps that many of us learn over long weekends. Early adopters
> will go through this, but it is a "crossing the chasm" item to be
> addressed.




- Original Message -
From: "Oleg Broytmann" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>
Cc: "Zope Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, September 13, 2000 1:24 PM
Subject: Re: [Zope] Simple dtml-unless problem


> On Wed, 13 Sep 2000, Tim Hicks wrote:
> > >Sometimes id is string, sometimes it is a function.
> > >
> > > 
> >
> > Thanks very much guys.  _['id'] fixed it.
>
>I hope you understand that I forced Zope to call the id()
function, but
> only if it is function. Else _['id'] just returns the id string.
>



Thanks Albert and Oleg. If I'm honest, while I have become somewhat
familiar with what Albert describes as zope's 'multiple personality
disorder', I can't say I truly understand it. I still don't think I've
got my head around the _['whatever'] syntax. From what Oleg says, if
there is a method there, it will be called, otherwise it reverts to a
string! Wow, that sounds like an awkward way to go about things. If I
have that point right, how would I force zope to treat it as a string
using the _[ syntax?

Cheers guys

tim


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




[Zope] dtml-in over the output from my method

2000-11-06 Thread Tim Hicks



I am trying to create a zope product in python but 
have got stuck with using the dtml-in tag to iterate over a method (or is it a 
function? I get a little mixed up) of my class. Here is the method,
 
    def 
list_messages(self):    
lr = open(self.user_dir+'/msg_list', 
'r')    
spl = 
re.compile('\s\|\s')    
for msg_line in 
lr.readline():    
num_from_sub = 
[]    
num_from_sub = spl.split(msg_line, 
2)    
print 
num_from_sub    
self.msgnum = 
num_from_sub[0]    
self.msgfrom = 'This is from 
UNKNOWN'    
self.msgsub = 'My special subject'
    
return self.msgnum, self.msgfrom, self.msgsub
 
And here is an extract from the dtml file that 
is supposed to display the output,
 
    
    
&dtml-msgfrom;    
&dtml-msgsub;    

However, this does not produce the desired effect. 
I don't know if it is obvious from what I've written, but basically, the three 
variables (self.msgnum, self.msgfrom and self.msgsub) are supposed to be 
inserted into the appropriate place in the table, and then the 'for' statement 
re-executed (producing different values for the variables) with the subsequent 
values being inserted into the next line of the table etc... until there are no 
more lines to be read from lr. I'm not sure if that is clear or not, sorry. 
Obviously, this does not work as the dtml-in simply iterates over each of the 
returned variables (instead of over the for statement). I can't seem to make it 
do what I want. Does anyone have any ideas? Much obliged if you do.
 
Cheers
 
tim
 


[Zope] testing a product, then it disappears after restart

2000-11-06 Thread Tim Hicks



I am trying to create a zope product and it 
basically works in python, so I thought I would start trying to 'zopify' it. I 
created a directory in the zope Products directory called zIMAP and placed my 
code in there, along with a __init__.py file to initialise the product. Here is 
what it looks like,
 
    import zIMAP
 
    def 
initialize(context):    """Initialize 
the zIMAP 
product."""    
    
context.registerClass(    
zMAP.zimap,constructors 
= (zIMAP.manage_addzIMAPForm, zIMAP.manage_addzIMAP), icon = 
'')
The main bit of my product code is in a file called 
zIMAP.py. When I restarted zope, my zIMAP product appeared in the product 
management list (broken, as I'd expected). I looked at the debug info that zope 
provides for broken products and made some changes to the code... followed by 
restarting zope. I then got a different error from the broken product info 
screen. However, when I made changes to the code and restarted zope this time, 
it was as if I had done nothing. The same error was there (despite that 
particular line of code being different, and in fact at a different line). I 
could not make zope recognise my changes no matter how many times I restarted 
zope. So I tried deleting the product from the product management screen. It did 
indeed go away, but now it won't come back! When I delete any other working 
product, it simply reappears next time I restart zope. What has gone wrong with 
my product? How can I make zope recognise it again?
 
I have included the top of my zIMAP.py file as well 
in case it is required.
 
I'd really appreciate any help.
 
tim
 
top of zIMAP.py
 
 
import imaplib, re, string, sys, os, 
DocumentTemplateimport Globalsfrom Globals import Persistent, 
Acquisitionimport AccessControlimport OFS
 
class zimap 
( Acquisition.Implicit, Persistent, AccessControl.Role.RoleManager, OFS.SimpleItem.Item, ):
 
 """zIMAP - Zope Product for displaying IMAP 
mailbox contents. """
 
 index_html =  
DocumentTemplate.HTMLFile("zIMAP1.dtml") manage_addzIMAPForm = 
Globals.HTMLFile('add_zIMAP', globals())
 
 meta_type = 'zIMAP (webmail)'
 
 def __init__(self, 
host):  self.host = host  self.product_root = 
'.'
 
 class email:
 
  def connect(self, user, 
passw):   self.user = user   self.passw = 
passw    
 self.M = 
imaplib.IMAP4(self.host)   self.M.login(self.user, 
self.passw)   self.user_dir = 
zimap.product_root+'/spool/'+self.user   email.makefiles(self)
 
...
 


Re: [Zope] dtml-in over the output from my method

2000-11-06 Thread Tim Hicks

- Original Message - 
From: Max M <[EMAIL PROTECTED]>
To: Tim Hicks <[EMAIL PROTECTED]>; Zope@Zope. Org <[EMAIL PROTECTED]>
Sent: Monday, November 06, 2000 9:48 PM
Subject: RE: [Zope] dtml-in over the output from my method




> 
> def list_messages(self):
> 
> class msg:
> def __init__(self, msgnum, msgfrom, msgsub):
> self.msgnum  = msgnum
> self.msgfrom = msgfrom
> self.msgsub  = msgsub
> 
> msgList = []
> lr = open(self.user_dir+'/msg_list', 'r')
> spl = re.compile('\s\|\s')
> for msg_line in lr.readline():
> num_from_sub = []
> num_from_sub = spl.split(msg_line, 2)
> 
> # Oh no ... this wont cut it!
> #self.msgnum = num_from_sub[0]
> #self.msgfrom = 'This is from UNKNOWN'
> #self.msgsub = 'My special subject'
> #return self.msgnum, self.msgfrom, self.msgsub
> 
> # Do it like this:
> msgList.append(msg(num_from_sub[0],'This is from UNKNOWN',
>'My special subject'))
>  return msgList
> 
> 

Brilliant, it works a treat. Thanks very much.

tim


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




[Zope] inserting half a dtml tag into a zclass

2000-12-27 Thread Tim Hicks



OK, I'm sorry for the wierd title, but I can't 
really describe what I want to say very easily in one line.
 
Basically, my problem is this;
 
- I have a zclass called DEHS with catalog_aware 
and dtml_document as base classes.
- DEHS instances have a selectable property of 
public/private.
- I want to be able to make it so that if the 
property is set to 'private', then only people on a particular network may 
access it. So, here is what I have done (and it works),
 

 

 

 

 
 
 

 
So, what's the problem I hear you ask.  Well, 
I don't really want all this code to be visible (or breakable) in every DEHS 
instance. What I would really like to do is have this,
 

 

 

 

 
where,  is just all of the 
code that I have above s_h_h. However, zope will not let me do this because 
I end up with a  that is missing its closing tag, and 
one that does not have an opening tag. I realise that I there are products 
already designed with the sort of functionality I am after built in, but I will 
not have much influence on the products that will be available on the server 
that this site will end up on... which is why I'm doing it in this 
way.
 
Any input is much appreciated.
 
cheers
 
tim


Re: [Zope] inserting half a dtml tag into a zclass

2001-01-10 Thread Tim Hicks


- Original Message -
From: Dieter Maurer <[EMAIL PROTECTED]>
To: Tim Hicks <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, December 29, 2000 9:38 AM
Subject: Re: [Zope] inserting half a dtml tag into a zclass


> Tim Hicks writes:
>  > This is a multi-part message in MIME format.
>  >
>  > --=_NextPart_000_0009_01C07071.533E96C0
>  > Content-Type: text/plain;
>  > charset="iso-8859-1"
>  > Content-Transfer-Encoding: quoted-printable
> You are here long enough: you should know, we do not like MIME
> messages.

My apologies. You're right, I do know better... my mistake.  Also, apologies
for the delayed reply, I've been away.

>
>  > ... isolating privacy checks ...
>  > 
>  > 
>  > 
>  > 
>
> I know about 2 possible approaches:
>
>  I. let your "privacy" method return a value (using "dtml-return")
> and check it above:
>
> 
>   ...header...
>   ...
>   ...footer...
> 
>

I've gone for a 'method' based on this first idea of yours.  Here is what
appears in each zclass instance.










And here is the privacy method.




















It's not perfect (that would be when there is nothing for the user to break
in each instance), but it's better than it was and also allows me to edit
only one privacy method to change the access rights.


>  II. I think (this implies, I am not sure), that ZPublisher
>  translates exceptions into HTTP response codes.
>  This would mean, you could try:
>
>In your "privacy" method:
>   
>   
>   
>   
>
>in your other objects:
>
>   
>   ...header...
>   
>   ...footer...
>

You've lost me a bit there.  Where am I actually checking to see if the user
has access rights?

Cheers

tim


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




[Zope] reindex when a zclass is edited

2001-01-10 Thread Tim Hicks

I know this has been asked numerous times before (once by me!), and I'm
sorry to cover the same ground again, but I've spent all afternoon searching
through the list archives to no avail. I have a zclass that is catalogaware
(selected first and all that).  When I add an instance, it gets cataloged
and all is fine.  I followed the how to
(http://www.zope.org/Members/AlexR/CatalogAware) and successfully made my
instance get reindexed when the properties are changed, but I can't for the
life of me figure out or find anywhere that can tell me how to make the
instance get reindexed when it is edited.  I'm assuming that it is similar
to the process for reindexing when the properties are changed, but I'm just
not sure of the details. If it's not too much trouble, could someone give me
detailed instructions (or a link) on how to do this. I'd really appreciate
it.

cheers

tim


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




Re: [Zope] reindex when a zclass is edited

2001-01-11 Thread Tim Hicks


- Original Message -
From: Ivan Cornell <[EMAIL PROTECTED]>
To: Tim Hicks <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, January 10, 2001 7:53 PM
Subject: Re: [Zope] reindex when a zclass is edited


> Tim Hicks wrote:
>
> >  I can't for the
> > life of me figure out or find anywhere that can tell me how to make the
> > instance get reindexed when it is edited.  I'm assuming that it is
similar
> > to the process for reindexing when the properties are changed, but I'm
just
> > not sure of the details. If it's not too much trouble, could someone
give me
> > detailed instructions (or a link) on how to do this. I'd really
appreciate
> > it.
> >
>
> In your method which is called by your edit form, insert a  "this().reindex_object()"> after updating the properties.
>
> Eg, in my manage_edit method I have
>
> 
> 
> 
>
> Regards, Ivan
>
>

Much obliged Ivan, I have managed to do it now.  I ended up creating
my_editForm and my_edit methods within the zclass and then using the source
from a builtin edit form as my template.  One thing doesn't work now though,
and that's making the textarea wider/narrow/etc.  Obviously, this is because
I have static values put in for the dimensions of the text area, but I'm not
sure how to alter this to make it work... any pointers?
my_edit looks like this btw,







Does this seem appropriate?

cheers

tim


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




[Zope] document_src not doing what I thought it did

2001-01-11 Thread Tim Hicks

I have a dtml-documentish zclass and have created a custom edit method for
it so that I can do an automatic reindex when each instance is edited.  I
created this custom form by simply copying the source html that is generated
for the standard edit form, and then replacing the static parts of what I
copied with various  inserts (see below).  This seemed to go
according to plan until I realised that something strange is happening when
I try to view this edit form for an instance of the zclass.  In most cases,
everything seems normal, but when I try to edit an instance that has a
property set to 'private', my 'privacy' method kicks in and redirects me
away from the edit form to my standard 'Restricted Page'.  The redirection
is written into the text of the instance I am trying to edit, so I expected
that by using , the actual source would get placed in
the text area without being processed.  This is what appears to happen when
the instance does not have the 'private' property.  I guess therefore, my
question is, am I using document_src correctly?

thanks very much

tim

ps Sorry to be such a regular poster of problems


  

  
 Id
 
  
  
 Title
 
  
 
  
  
 
Size

 
 bytes
 
  
  
 
Last modified

 

 
  
  
 
 
 
  
  
 
  
 
 
   
   
   
   
 
  

  


___
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] document_src not doing what I thought it did

2001-01-13 Thread Tim Hicks


- Original Message -
From: Dieter Maurer <[EMAIL PROTECTED]>
To: Tim Hicks <[EMAIL PROTECTED]>
Sent: Friday, January 12, 2001 10:28 PM
Subject: Re: [Zope] document_src not doing what I thought it did


> Tim Hicks writes:
>  > I have a dtml-documentish zclass and have created a custom edit method
for
>  > it so that I can do an automatic reindex when each instance is edited.
I
>  > created this custom form by simply copying the source html that is
generated
>  > for the standard edit form, and then replacing the static parts of what
I
>  > copied with various  inserts (see below).  This seemed to go
>  > according to plan until I realised that something strange is happening
when
>  > I try to view this edit form for an instance of the zclass.  In most
cases,
>  > everything seems normal, but when I try to edit an instance that has a
>  > property set to 'private', my 'privacy' method kicks in and redirects
me
>  > away from the edit form to my standard 'Restricted Page'.  The
redirection
>  > is written into the text of the instance I am trying to edit, so I
expected
>  > that by using , the actual source would get
placed in
>  > the text area without being processed.  This is what appears to happen
when
>  > the instance does not have the 'private' property.  I guess therefore,
my
>  > question is, am I using document_src correctly?
> Is is possible that your edit form is called
> in the context of you ZInstance?
>

I'm not sure I completely understand the terminology you use, but I guess it
sounds right that the edit form method is called 'on' (in my terminology
;-) ) the Zclass instance.  It is in that way that the  retrieve the attributes of the instance and not the
method itself... is that correct? Is that what you mean?

> Then, it might be able that *it* interpretes the "private"
> and redirects before "document_src" is executed at all.

Each Zclass instance has blah . (*
set by the privacy method).  Thanks for your help with that btw :-).
However, the edit form method does not have this code in it.  As far as I
can gather, the only time the method gets to 'see' the code shown above is
when it inserts .

What am I missing?

tim


>
>
> Dieter
>


___
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] reindex when a zclass is edited

2001-01-13 Thread Tim Hicks


- Original Message -
From: Aleksander Salwa <[EMAIL PROTECTED]>
To: Tim Hicks <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, January 12, 2001 8:34 AM
Subject: Re: [Zope] reindex when a zclass is edited


>
> On Thu, 11 Jan 2001, Tim Hicks wrote:
>
> > from a builtin edit form as my template.  One thing doesn't work now
though,
> > and that's making the textarea wider/narrow/etc.  Obviously, this is
because
> > I have static values put in for the dimensions of the text area, but I'm
not
> > sure how to alter this to make it work... any pointers?
>
> I use this code for that purpose:
>
> 
>  
>"manage_edit(data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST)">
>  
>   
>  
> 
>  
>"manage_edit(data,title,SUBMIT,dtpref_rows=dtpref_rows,REQUEST=REQUEST)">
>  
>   
>  
> 
> 
> 
>
>

Thanks very much for the help Aleksander, but when I drop your code into my
method, it doesn't work (it doesn't break either). I simply copied and
pasted your code, then edited the final redirect at the bottom.  Here is the
submission part of my edit form (if it makes any difference).


  
 
 
   
   
   
   
 

I had a look on the ZQR, and found the section on manage_edit, but I still
don't really understand how the dtpref_cols/rows works.  Any insight?

Cheers

tim


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




[Zope] Script to do various 'manage_' operations

2001-01-27 Thread Tim Hicks

I have been trying to get hold of a script that can automatically convert
various dtml methods to custom zclass instances.  I found a script on the
zope mailing list (see bottom)

I put my file (see below) in the Extensions directory and added an external
method from within zope.  This all appeared to go fine.  To execute the
script, I made a method that simply had  and then
standard_h_h etc.  The problem is, nothing seems to happen.  I can view the
method that was supposed to run the script, but the call doesn't seem to
work.  Within the filesystem, there is no file called tempo (as a kind of
log of what's been done), and the methods with extension .shtml certainly do
not get changed to dtml documents.

Has anyone done this before?  Can you shed any light on what I'm doing
wrong?

Much obliged.

tim


Script from [EMAIL PROTECTED]
---

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('<\g<1>dtml-\g<2>>', data)
 print 'newdata'
 print newdata
 print 'end'
 dtml_item.manage_edit(newdata, title)


--
And here is how I adjusted it for my purposes:
--

import re

get_shtml = re.compile('\w+\.shtml')
f = open("tempo", "w+")

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.
 """
 if hasattr(self, 'meta_type') and \
 get_shtml.match(self.id):
 convert(self)

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

def convert(dtml_item):
 id = dtml_item.id+'2'
 title = dtml_item.title
 # like document_src, but doesn't require RESPONSE
 f.write(id /n)
 data = dtml_item.PrincipiaSearchSource()
 PARENTS[0].manage_addDTMLDocument(id, title)
 id.manage_edit(data, title)







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




[Zope] Security on email.Message.Message

2005-04-12 Thread Tim Hicks
Hi,

I'm trying to import and use the email.Message.Message class in a zope
'Script (Python)'.

I have the following security assertions in my product code::

  from AccessControl import allow_module, allow_class
  from AccessControl import ModuleSecurityInfo

  ModuleSecurityInfo('email.Message').declarePublic('Message')
  from email.Message import Message
  allow_class(Message)

As a result, I can successfully import like::

  from email.Message import Message

I can even create an instance and call most methods on it::

  m = Message()
  m.set_payload('read that')

However, when I try to use the mapping interface, I get an error.  For
example, the following::

  m['from'] = '[EMAIL PROTECTED]'

produces a traceback like::

  Traceback (innermost last):
Module ZPublisher.Publish, line 101, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 39, in call_object
Module Shared.DC.Scripts.Bindings, line 306, in __call__
Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 323, in _exec
Module None, line 6, in AAA
 - 
 - Line 6
Module RestrictedPython.Guards, line 96, in handler
  TypeError: object does not support item or slice assignment

Does anyone have any idea what the problem is?


Tim

ps Not subscribed here, so please do cc me with replies.
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Security on email.Message.Message

2005-04-12 Thread Tim Hicks
Andreas Jung said:

>> Module RestrictedPython.Guards, line 96, in handler
>>   TypeError: object does not support item or slice assignment
>>
>> Does anyone have any idea what the problem is?
>
> Move your code into an external method which is less painful than dealing
> with module security issues. As an alternative: look at
> TrustedExecutables.

Thanks Andreas.

I suppose I could move the code to a product (which I would prefer over an
external method), but it seems a little heavy-weight for my requirements.

In fact, generally, I think I would like to be able to use
email.Message.Message instances in TTW code, so if anyone does know what's
going wrong here, I'd be most pleased to hear.

Tim

ps Is it me or is the traceback I'm seeing not particularly helpful?  I
mean, I know that these objects *do* support the dictionary interface!
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Security on email.Message.Message

2005-04-12 Thread Tim Hicks
Andreas Jung said:

>> Module RestrictedPython.Guards, line 96, in handler
>>   TypeError: object does not support item or slice assignment
>>
>> Does anyone have any idea what the problem is?

Digging further...

I made the TypeError a little more revealing on line 96 of
RestrictedPython/Guards.py so it now shows the 'secattr' (method) being
accessed, and its args::

def handler(self, *args):
try:
f = getattr(self.ob, secattr)
except AttributeError:
raise TypeError, '%s | %s | %s' % (error_msg, secattr,
str(args))

The value of 'secattr' is apparently '__guarded_setitem__' in my case. 
So, it seems that the email.Message.Message class does not have a
__guarded_setitem__ on it.  This is unsurprising.  I assume that it is
supposed to get added during zope initialisation somewhere, right?  Can
anybody point out where?

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


Re: [Zope] Security on email.Message.Message

2005-04-12 Thread Tim Hicks
Tim Hicks said:
> Andreas Jung said:
>
>>> Module RestrictedPython.Guards, line 96, in handler
>>>   TypeError: object does not support item or slice assignment
>>>
>>> Does anyone have any idea what the problem is?
>
> Digging further...
>
> I made the TypeError a little more revealing on line 96 of
> RestrictedPython/Guards.py so it now shows the 'secattr' (method) being
> accessed, and its args::
>
> def handler(self, *args):
> try:
> f = getattr(self.ob, secattr)
> except AttributeError:
> raise TypeError, '%s | %s | %s' % (error_msg, secattr,
> str(args))
>
> The value of 'secattr' is apparently '__guarded_setitem__' in my case.
> So, it seems that the email.Message.Message class does not have a
> __guarded_setitem__ on it.  This is unsurprising.  I assume that it is
> supposed to get added during zope initialisation somewhere, right?  Can
> anybody point out where?

Well, I've fixed this with an awful hack.  My security assertions now look
like::

  from AccessControl import allow_module, allow_class
  from AccessControl import ModuleSecurityInfo

  def _secure_mapping(klass):
  """XXX Awful hack!!
  """
  klass.__guarded_getitem__ = klass.__getitem__
  klass.__guarded_setitem__ = klass.__setitem__
  klass.__guarded_delitem__ = klass.__delitem__

  ModuleSecurityInfo('email.Message').declarePublic('Message')
  from email.Message import Message
  _secure_mapping(Message)
  allow_class(Message)

That gets me to where I want (for now).  I'd still love the 'correct'
answer though.


Tim

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


[Zope] blacklisting referers and/or specific hosts

2005-07-03 Thread Tim Hicks
Hi,

I have a zope site up and running which has recently had a *lots* of hits
from a client (or clients) that show referers pointing at various
gambling, meds, and loan sites.  Requests only come in for the main page,
not for the associated images, css, etc that should go with it.

The consequence is that my server is working harder to service a client
that isn't interested in what it has to say, and my Z2.log is now far less
useful to me as all these bogus requests drown out most of the useful
information.

So, I'm wondering if there's a way to blacklist those clients that I don't
like based on host/ip and/or on referer.

If I hook into the traversal process in the same way as the virtual host
monster objects do, could I check the request against my blacklist and
then do a REQUEST.close()?  Would that still appear in my logs?  Does that
even make sense?  Is there a HTTP response code that I could return to
these clients that would stop them being interested in my server?

Any ideas much appreciated.

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


Re: [Zope] blacklisting referers and/or specific hosts

2005-07-04 Thread Tim Hicks
David Pratt wrote:
> Hi Tim.  I think what Jens has to say is the best solution. I have also
> made my own thing with zope as well since I don't always have control
> of the firewall.

Yes, this is the problem I have.  I'm hosted on zettai, so am a little
limited in the options available to me (I believe).  Zettai have said they
will have a solution in place within 2-3 months, but I'd really like to
sort something out in the meantime.

>  I worked out a simple ip and country-ip solution. I
> made a simple interface for adding ips to a black list or selecting
> countries to add to black list. The logic makes a final connection to
> my main site template so ips in black list or ip turning out to be from
> a black listed country get nothing but an empty page (including an
> empty page header) while those that I want to view my site will get
> rendered pages.  I use a county-ip database that gets updated once per
> week (about 50,000 records) representing ranges from all countries.

Blimey, 50,000 records sounds pretty heavy (for my purposes)!  As far as I
can tell, there are two or three IP addresses producing all of these pesky
requests.  Do you have code that you can share?

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