RE: [Zope] Help wanted on Zope ZClasses/DTML please.

2000-11-06 Thread Seb Bacon


 I have worked out thanks to Seb's comments that the problem I
 have with the
 use of manage_delObjects is (I think) that I am passing in the title or id
 of the object to be deleted rather than the object itself.

Not quite... manage_delObjects takes a string which is the id of the object
to be deleted.  Your example

dtml-call "manage_delObjects('the_id')"

was passing a string 'the_id' to the method.  I might have interpreted what
you were trying to do wrongly, but I believe you actually wanted to pass the
_value_ of the_id.

 I want to put the object into the REQUEST so I can still access it from a
 different namespace - at the point I want to do the deletion, my target
 object is out of scope.

In fact you just have to put the correct string into the REQUEST and then
make sure you have the object you're trying to reference in your current
namespace, e.g. by using dtml-with foo_namespacedtml-var
"manage_delObjects(the_id)"/dtml-with.  If you need more help, post the
snippet you're working on again.

seb.


___
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 wanted on Zope ZClasses/DTML please.

2000-11-06 Thread Bowyer, Alex

Thanks for the e-mail Seb. I am afraid I am still having problems here, so I
will show my code again, and hopefully you or someone else will be able to
help.

To recap : I am creating a news page and an interface to edit it using two
custom ZClasses, Article and Page. A Page object contains several Articles.
The following code is from a script that allows the user to delete an
Article from the Page. This method belongs to the Page class, so we are
currently in the scope of the Page. This script is supplied with the title
of a news article to be deleted, it should then delete the Article from the
Page and report back.

dtml-var standard_header
!-- set this flag to null so I can tell if/when matching article found --
dtml-call "REQUEST.set('id_to_delete','NULL')"
!-- retrieve the title of the article to delete --
dtml-let the_match="REQUEST['article_to_delete']"
!-- start cycling through Articles looking for a match --
dtml-in objectValues
  dtml-with sequence-item
  dtml-with propertysheets
  dtml-with UAArticleClassPropertySheet
  !-- now we are looking at the properties of one of the Articles --
  dtml-if expr="article_title==the_match"
dtml-call "REQUEST.set('id_to_delete',title_or_id)"
!-- this is the point where we have located the article to delete.
Ideally we should delete it now, 
 but we are still in the scope of the property sheet --
  /dtml-if
  /dtml-with/dtml-with
  !-- now if we have found a match, we are back in the scope of the
objectValues of the Page, 
   so we want to do the deletion. --
  dtml-unless expr="REQUEST['id_to_delete']=='NULL'"
dtml-let the_id="REQUEST['id_to_delete']"
  !-- this is the problem line --
  dtml-call "manage_delObjects(the_id)"
/dtml-let
  /dtml-unless
/dtml-in
!-- this last bit just generates HTML to say if deletion done or article
not found --
dtml-if expr="REQUEST['id_to_delete']=='NULL'"
  h2Article not found/h2
  PCould not find the article to delete./PPA HREF=editReturn to
maintenance page/A/P
dtml-else
  h2Article not deleted/h2
  PDeleted article 'dtml-the_match;' (id='dtml-the_id;')./PPA
HREF=editReturn to maintenance page/A/P
/dtml-if
/dtml-let
dtml-var standard_footer
!-- end of code --

Basically I think I am somehow passing the wrong parameters to
manage_delObjects

The line
  dtml-call "manage_delObjects(the_id)"
causes an error 'loop over non-sequence'

This made me think that the argument has to be a sequence so I tried
  dtml-call "manage_delObjects('the_id')"
but this fails because as you say it looks for an object called the_id and I
need to pass in the value of the_id not the name of it.

Ideally I want to say
dtml-call "manage_delObjects(REQUEST['id_to_delete'])"
but again this fails to find the object.

Any ideas?

Thanks for helping,

Alex

 -Original Message-
 From: Seb Bacon [mailto:[EMAIL PROTECTED]]
 Sent: Monday, November 06, 2000 8:50 PM
 To: Bowyer, Alex; [EMAIL PROTECTED]
 Subject: RE: [Zope] Help wanted on Zope ZClasses/DTML please.
 
 
 
  I have worked out thanks to Seb's comments that the problem I
  have with the
  use of manage_delObjects is (I think) that I am passing in 
 the title or id
  of the object to be deleted rather than the object itself.
 
 Not quite... manage_delObjects takes a string which is the id 
 of the object
 to be deleted.  Your example
 
 dtml-call "manage_delObjects('the_id')"
 
 was passing a string 'the_id' to the method.  I might have 
 interpreted what
 you were trying to do wrongly, but I believe you actually 
 wanted to pass the
 _value_ of the_id.
 
  I want to put the object into the REQUEST so I can still 
 access it from a
  different namespace - at the point I want to do the 
 deletion, my target
  object is out of scope.
 
 In fact you just have to put the correct string into the 
 REQUEST and then
 make sure you have the object you're trying to reference in 
 your current
 namespace, e.g. by using dtml-with foo_namespacedtml-var
 "manage_delObjects(the_id)"/dtml-with.  If you need more 
 help, post the
 snippet you're working on again.
 
 seb.
 

___
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 wanted on Zope ZClasses/DTML please.

2000-11-03 Thread Seb Bacon

Hi, just some quick pointers (I'm in a hurry...)

refer to http://zdp.zope.org/projects/zqr/ZopeQR for more details

   !-- do the deletion - this is the bit that doesn't work --
   dtml-call "manage_delObjects('the_id')"
 What is the correct way to use manage_delObjects?

   dtml-call "manage_delObjects(the_id)"

should work.  What you wrote looks for an object with id "the_id".  In fact
you want the value of the_id, which is evaluated for you when it's in quotes
(think of everything in quotes as python).

 Is there a way to get the
 name of an object's parent (or its own name for that matter) and use it to
 construct a URL?

dtml-var "PARENTS[0]" gives you the parent

 3) When redirecting or linking to a page I have already visited, how can I
 force a refresh? I tried the JavaScript window.location.reload(true) but I
 think that is only supported by Netscape. It didn't work in IE5 for me
 anyway.

window.location.reload() works for me...

 4) What is the best way to handle security with ZClasses. In my example I
 want the index_html pages to be public but everything else to require a
 password. I managed to require a password for a particular instance of the
 UAPage, but that affects both the index_html and the edit pages.

you can attach permissions to specific methods in a ZClass by mapping them
to existing permissions in the 'define permissions' management tab.

cheers,

seb.


___
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 wanted on Zope ZClasses/DTML please.

2000-11-03 Thread chip johansen

Instead of ...

dtml-call
"manage_delObjects('REQUEST['id_to_delete']')"

try

dtml-call
"manage_delObjects('REQUEST.id_to_delete')"

Chip Johansen

From: "Bowyer, Alex" [EMAIL PROTECTED]
To: "'[EMAIL PROTECTED]'" [EMAIL PROTECTED]
Subject: [Zope] Help wanted on Zope ZClasses/DTML please.
Date: Fri, 3 Nov 2000 16:05:49 +1100

Hi,

I have only just started developing in Zope over this last week. I like it 
a
lot, but I am having problems finding solutions to some of my more specific
problems in the various zope documentations. I am hoping that if I describe
my problems, one of you more-experienced Zope users out there will be able
to help me.

First some background:

Basically I have written a news page which allows you to add/edit/delete
articles from it. It is similar in some ways to the Zope HowTo "Build a
searchable job board". It revolves around two classes:

(UA stands for Update Australia, the name of the news page)

UAArticle : A single article, to be included on the page.
-
Properties:
  article_title,article_author and article_text (self-explanatory)
DTML Methods:
  index_html - renders the data from the three properties into HTML ready 
for
inclusion in the news page
  edit - a page with a form to allow you to modify the content, submits to
"update"
  update - processes the form results from "edit", updates the properties 
and
redirects

UAPage : the page itself, inherits from ObjectManager and has Add UAArticle
permission defined. Each instance contains 0 or more UAArticles.
--
Properties:
  issue_date, issue_number, intro_text (self-explanatory)
Methods:
  index_html - renders the page to HTML, both from these properties and by
calling the index_html of each subcomponent UAArticle.
  edit - a set of forms for modifications to edit the above three 
properties
and add a new article, or select an article to edit or delete.
  update - processes updates to the UAPage properties that have been made 
on
the edit page.
  edit_article - once an article is selected and the Edit button is 
clicked,
this finds the article, calls the edit method and gives feedback.
  add_article - a form to create a new article and add it to the UAPage.
  create_article - processes the data from the add_article form and 
actually
makes the object and adds it.
  delete_article - once an article is selected and the Delete button is
clicked, this finds the article, deletes it and gives feedback.

Now to the problems I have got:

1) I cannot get my delete_article method to work. I figured I need to use
manage_delObjects, but I can't find a working example to copy from and my
code doesn't seem to do anything. The following code gets called by a form
with a field called article_to_delete which is the title of the article we
want to delete:

dtml-var standard_html_header
!-- set a flag to NULL, change it if found --
dtml-call "REQUEST.set('id_to_delete','NULL')"
!-- get the title of the article to delete --
dtml-let the_match="REQUEST['article_to_delete']"
!-- search for the article --
dtml-in objectValues
   dtml-with sequence-itemdtml-with propertysheetsdtml-with
UAArticleClassPropertySheet
   dtml-if expr="article_title==the_match"
 dtml-call "REQUEST.set('id_to_delete',title_or_id)"
 !-- found it, update the flag --
   /dtml-if
   /dtml-with/dtml-with/dtml-with
/dtml-in
!-- test the flag to see if found --
dtml-if expr="REQUEST['id_to_delete']=='NULL'"
   !-- not found --
   h2Article not found/h2
   PCould not find the article to delete./PPA HREF=editReturn to
maintenance page/A/P
dtml-else
   !-- found --
   dtml-let the_id="REQUEST['id_to_delete']"
   !-- do the deletion - this is the bit that doesn't work --
   dtml-call "manage_delObjects('the_id')"
   h2Article deleted/h2
   PDeleted article 'dtml-the_match;' (id='dtml-the_id;')./PPA
HREF=editReturn to maintenance page/A/P
   /dtml-let
/dtml-if
/dtml-let
dtml-var standard_html_footer

This gets an error that the_id does not exist. But I can't put dtml-call
"manage_delObjects('REQUEST['id_to_delete']')" because that is quotes
within quotes within quotes. I also tried  dtml-with the_iddtml-call
"manage_delObjects()"/dtml-with but that doesn't seem to do anything.
What is the correct way to use manage_delObjects?

2) I need to be able to make a "Back" button on the UAArticle's edit page
that will return to the UAPage's edit page. The problem is that if I use A
HREF=edit it just goes to the edit page of the object, because our current
location is within the UAArticle not the UAPage. Is there a way to get the
name of an object's parent (or its own name for that matter) and use it to
construct a URL?

3) When redirecting or linking to a page I have already visited, how can I
force a refresh? I tried the JavaScript window.location.reload(true) but I
think that is only supported by Netscape. It didn't work in IE5 for me
anyway.

4) What is the best way to handle security with ZClasses. In my example I
want the index_html pages to be public but everything 

Re: [Zope] Help wanted on Zope ZClasses/DTML please.

2000-11-03 Thread Andy McKay

or try: dtml-call "manage_delObjects(REQUEST['id_to_delete'])"

- Original Message -
From: "chip johansen" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, November 03, 2000 9:01 AM
Subject: Re: [Zope] Help wanted on Zope ZClasses/DTML please.


 Instead of ...

 dtml-call
 "manage_delObjects('REQUEST['id_to_delete']')"

 try

 dtml-call
 "manage_delObjects('REQUEST.id_to_delete')"

 Chip Johansen

 From: "Bowyer, Alex" [EMAIL PROTECTED]
 To: "'[EMAIL PROTECTED]'" [EMAIL PROTECTED]
 Subject: [Zope] Help wanted on Zope ZClasses/DTML please.
 Date: Fri, 3 Nov 2000 16:05:49 +1100
 
 Hi,
 
 I have only just started developing in Zope over this last week. I like
it
 a
 lot, but I am having problems finding solutions to some of my more
specific
 problems in the various zope documentations. I am hoping that if I
describe
 my problems, one of you more-experienced Zope users out there will be
able
 to help me.
 
 First some background:
 
 Basically I have written a news page which allows you to add/edit/delete
 articles from it. It is similar in some ways to the Zope HowTo "Build a
 searchable job board". It revolves around two classes:
 
 (UA stands for Update Australia, the name of the news page)
 
 UAArticle : A single article, to be included on the page.
 -
 Properties:
   article_title,article_author and article_text (self-explanatory)
 DTML Methods:
   index_html - renders the data from the three properties into HTML ready
 for
 inclusion in the news page
   edit - a page with a form to allow you to modify the content, submits
to
 "update"
   update - processes the form results from "edit", updates the properties
 and
 redirects
 
 UAPage : the page itself, inherits from ObjectManager and has Add
UAArticle
 permission defined. Each instance contains 0 or more UAArticles.
 --
 Properties:
   issue_date, issue_number, intro_text (self-explanatory)
 Methods:
   index_html - renders the page to HTML, both from these properties and
by
 calling the index_html of each subcomponent UAArticle.
   edit - a set of forms for modifications to edit the above three
 properties
 and add a new article, or select an article to edit or delete.
   update - processes updates to the UAPage properties that have been made
 on
 the edit page.
   edit_article - once an article is selected and the Edit button is
 clicked,
 this finds the article, calls the edit method and gives feedback.
   add_article - a form to create a new article and add it to the UAPage.
   create_article - processes the data from the add_article form and
 actually
 makes the object and adds it.
   delete_article - once an article is selected and the Delete button is
 clicked, this finds the article, deletes it and gives feedback.
 
 Now to the problems I have got:
 
 1) I cannot get my delete_article method to work. I figured I need to use
 manage_delObjects, but I can't find a working example to copy from and my
 code doesn't seem to do anything. The following code gets called by a
form
 with a field called article_to_delete which is the title of the article
we
 want to delete:
 
 dtml-var standard_html_header
 !-- set a flag to NULL, change it if found --
 dtml-call "REQUEST.set('id_to_delete','NULL')"
 !-- get the title of the article to delete --
 dtml-let the_match="REQUEST['article_to_delete']"
 !-- search for the article --
 dtml-in objectValues
dtml-with sequence-itemdtml-with propertysheetsdtml-with
 UAArticleClassPropertySheet
dtml-if expr="article_title==the_match"
  dtml-call "REQUEST.set('id_to_delete',title_or_id)"
  !-- found it, update the flag --
/dtml-if
/dtml-with/dtml-with/dtml-with
 /dtml-in
 !-- test the flag to see if found --
 dtml-if expr="REQUEST['id_to_delete']=='NULL'"
!-- not found --
h2Article not found/h2
PCould not find the article to delete./PPA HREF=editReturn to
 maintenance page/A/P
 dtml-else
!-- found --
dtml-let the_id="REQUEST['id_to_delete']"
!-- do the deletion - this is the bit that doesn't work --
dtml-call "manage_delObjects('the_id')"
h2Article deleted/h2
PDeleted article 'dtml-the_match;' (id='dtml-the_id;')./PPA
 HREF=editReturn to maintenance page/A/P
/dtml-let
 /dtml-if
 /dtml-let
 dtml-var standard_html_footer
 
 This gets an error that the_id does not exist. But I can't put dtml-call
 "manage_delObjects('REQUEST['id_to_delete']')" because that is quotes
 within quotes within quotes. I also tried  dtml-with the_iddtml-call
 "manage_delObjects()"/dtml-with but that doesn't seem to do anything.
 What is the correct way to use manage_delObjects?
 
 2) I need to be able to make a "Back" button on the UAArticle's edit page
 that will return to the UAPage's edit page. The problem is that if I use
A
 HREF=edit it just goe