Re: [Zope3-Users] How to redirect to a view after adding an object

2005-10-31 Thread Dominik Huber

Martin Margo wrote:


Hello

Sorry if this was asked before. I did some basic search and couldn't
find anything. I am new to Zope3 myself.

After reading Stephan and Von Weitershausen's book on Zope 3, I begin
building my own web application. My question is :

After my user adds a new custom object (type CandyBar) through
http://site/+/AddCandyBar.html=,   how do I redirect the user to a
custom view (the custom view is called
browser/CandyBarPurchaseConfirm.pt)?
 


Do you use browser:addform of the form framework?

If so, you have to provide your own view class overwriting the nextURL 
method. Be careful your view is used for the adaption of '+' (the adding 
view of the container). Therefore the self.context is referencing the 
'+' and the self.context.context the underlying container:


class AddView(object):

   def nextURL(self):
   return zapi.absoluteURL(self.context.context, self.request) + 
'/@@anyurl.html'


browser:addform
   class=module.AddView
   ...
   /

Regards,
Dominik
begin:vcard
fn:Dominik Huber
n:Huber;Dominik
email;internet:[EMAIL PROTECTED]
tel;work:++41 56 534 77 30
x-mozilla-html:FALSE
version:2.1
end:vcard

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Help us! Calling a Python Script from ZPT

2005-10-31 Thread Jean-Marc Orliaguet
Wade Leftwich wrote:

 Stephan Richter wrote:



 Why not have those templates on the file system? Is there a need for
 users to modify those templates?


 Yes, users with the job description web producers, which is to say
 people who can do HTML and a bit of scripting, but who do not get
 access to the file system. Kind of like the Zope 2 model. We even use
 acquisition.

 Also, it seemed to me unwieldy to put 50 directories in the filesystem
 to contain the templates for all the sites. But because of my
 experience with Zope 2, I assumed TTW was the best way to customize
 the application for each site, and I guess I should re-examine that
 assumption.

Hi!
there is indeed such a category of users, i.e. somewhere between
filesystem developers and application users. There will be support for
this kind of TTW editing in cpsskins (cf Custom Portlet), but it will be
purely limited to simple presentation  logic.

cf. http://www.z3lab.org/sections/front-page/design-features/custom-portlet

the difference with the Zope2 model I think is that web producers are
not going to be ZPT programmers, but more like site composers with the
ability to do minimal TTW template editing such as shown in the animation.

/JM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Validation of schemas?

2005-10-31 Thread gnotari
[EMAIL PROTECTED] wrote on 31/10/2005 06.12.43:


 Just added this to FAQ (http://zissue.berlios.de/z3/z3faq.html).
 I expects more contribution  in coming months.


 How to validate two or more fields simultaneously?
 ~~

 Use `invariants` to control more fields.

 Look at zope.interface/README.txt for details.

 Let's consider this more specific question asked to list:

   How do I implement a validation rule that says either email or phone
   have to exist, but not necissarily both.

   Using the buddy demo as an example, with the following interface::

 class IBuddy(zope.interface.Interface):
 Provides access to basic buddy information

 fullname = TextLine(title=_(Name))
 email = TextLine(title=_(Email Address))
 phone = TextLine(title=_(Phone Contact))

 First we have to make a callable object, either a simple function or
 callable instance of a class::

   def contacts_invariant(obj):
   if not (obj.email or obj.phone):
   raise Exception(At least one contact info is rquired)

 Now use `validateInvariants` method of the interface to validate::

   buddy = Buddy()
   buddy.email = u[EMAIL PROTECTED]
   IBuddy.validateInvariants(buddy)

What I would want to be further explained is: When should I call
validateInvariants?
Of course I would call it when I'm creating or editing the object. Then,
frequently, just after an add or edit form.
More: can I then use auto generated forms (by using events after the form,
but how?), or I just have do define a custom form?
And then: what do I do if the validation falils? How do I return the form,
possibly with an error message?

I feel these are genuine FAQs, and I still don't have answers for many of
them. Working through them at a steday pace, though ;)
Thanks for all your help, really.

ciao
Guido

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Help us! Calling a Python Script from ZPT

2005-10-31 Thread Wade Leftwich

Jean-Marc Orliaguet wrote:

Wade Leftwich wrote:



Stephan Richter wrote:




Why not have those templates on the file system? Is there a need for
users to modify those templates?



Yes, users with the job description web producers, which is to say
people who can do HTML and a bit of scripting, but who do not get
access to the file system. Kind of like the Zope 2 model. We even use
acquisition.

Also, it seemed to me unwieldy to put 50 directories in the filesystem
to contain the templates for all the sites. But because of my
experience with Zope 2, I assumed TTW was the best way to customize
the application for each site, and I guess I should re-examine that
assumption.



Hi!
there is indeed such a category of users, i.e. somewhere between
filesystem developers and application users. There will be support for
this kind of TTW editing in cpsskins (cf Custom Portlet), but it will be
purely limited to simple presentation  logic.

cf. http://www.z3lab.org/sections/front-page/design-features/custom-portlet

the difference with the Zope2 model I think is that web producers are
not going to be ZPT programmers, but more like site composers with the
ability to do minimal TTW template editing such as shown in the animation.

/JM




Yes, that's the kind of user I'm talking about, and the Custom Portlet 
tool looks really good. Cool animation, too. I've been planning to check 
out the Z3ECM project, but am trying to get a better grasp of Zope 3 
itself first.


-- Wade Leftwich

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users