[Zope3-Users] nextURL: add vs edit

2006-02-17 Thread Shaun Cutts








Is there a reason why zope.app.form.browser.add.AddView
defines:



 def nextURL(self):

 return self.context.nextURL()



but zope.app.form.browser.editview.EditView doesnt?



My redirection works for add but not edit, and this is the
reason. Is this a feature or a bug? If a bug, all that needs to happen is that nextURL get moved to EditView
from AddView, as EditView
is base for Add. 



But perhaps there is a reason for this I dont
understand?



- Shaun






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


RE: [Zope3-Users] nextURL: add vs edit

2006-02-17 Thread Shaun Cutts
Ok,

In AddView.update,

self.request.response.redirect(self.nextURL())

is called, but this is not called in EditView... so change isn't as
simple as moving nextURL. However, if you put this line into
EditView.update as well as moving nextURL, then my redirect works fine.

But does this break anything else? Is there some reason why the editview
doesn't do redirect? 

I have gotten offlist feedback that I'm not the only one interested in
this

Thanks,
- Shaun

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Shaun Cutts
Sent: Friday, February 17, 2006 1:17 PM
To: Zope3-users@zope.org
Subject: [Zope3-Users] nextURL: add vs edit

Is there a reason why zope.app.form.browser.add.AddView defines:

def nextURL(self):
return self.context.nextURL()

but zope.app.form.browser.editview.EditView doesn't?

My redirection works for add but not edit, and this is the reason. Is
this a feature or a bug? If a bug, all that needs to happen is that
nextURL get moved to EditView from AddView, as EditView is base for Add.


But perhaps there is a reason for this I don't understand?

- Shaun


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


Re: [Zope3-Users] nextURL: add vs edit

2006-02-17 Thread Gary Poster


On Feb 17, 2006, at 1:42 PM, Shaun Cutts wrote:


Ok,

In AddView.update,

self.request.response.redirect(self.nextURL())

is called, but this is not called in EditView... so change isn't as
simple as moving nextURL. However, if you put this line into
EditView.update as well as moving nextURL, then my redirect works  
fine.


But does this break anything else? Is there some reason why the  
editview

doesn't do redirect?

I have gotten offlist feedback that I'm not the only one interested in
this

Thanks,
- Shaun


This behavior is by design.

add forms need the nextURL because it is advisory to the IAdding.

edit forms can just use the changed hook to call  
self.request.response.redirect('http://whereever.you.want/to/go')


Or use formlib, and be able to be fully in charge the way you'll  
eventually want to be.


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


RE: [Zope3-Users] nextURL: add vs edit

2006-02-17 Thread Garanin Michael
Difference beetween AddView and EndView
1) for AddView: 'self.context' is view (name '+')
2) for EditView : 'self.context' is content-object

I think this is 'standart' behavior. Use 'zope.formlib' for advanced
customization your forms. 

В Птн, 17/02/2006 в 13:42 -0500, Shaun Cutts пишет:
 Ok,
 
 In AddView.update,
 
 self.request.response.redirect(self.nextURL())
 
 is called, but this is not called in EditView... so change isn't as
 simple as moving nextURL. However, if you put this line into
 EditView.update as well as moving nextURL, then my redirect works fine.
 
 But does this break anything else? Is there some reason why the editview
 doesn't do redirect? 
 
 I have gotten offlist feedback that I'm not the only one interested in
 this
 
 Thanks,
 - Shaun
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of
 Shaun Cutts
 Sent: Friday, February 17, 2006 1:17 PM
 To: Zope3-users@zope.org
 Subject: [Zope3-Users] nextURL: add vs edit
 
 Is there a reason why zope.app.form.browser.add.AddView defines:
 
 def nextURL(self):
 return self.context.nextURL()
 
 but zope.app.form.browser.editview.EditView doesn't?
 
 My redirection works for add but not edit, and this is the reason. Is
 this a feature or a bug? If a bug, all that needs to happen is that
 nextURL get moved to EditView from AddView, as EditView is base for Add.
 
 
 But perhaps there is a reason for this I don't understand?
 
 - Shaun
 
 
 ___
 Zope3-users mailing list
 Zope3-users@zope.org
 http://mail.zope.org/mailman/listinfo/zope3-users

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


RE: [Zope3-Users] nextURL: add vs edit

2006-02-17 Thread Shaun Cutts
Ok -- 

Thanks Gary and Michael.

I've defined changed in my mixin, and it works:

def changed( self ):
self.request.response.redirect(self.nextURL())

And I can still use the same mixin to do redirect for both edit and add
forms, so I can't grumble about that.

I'm curious how this works, however, since EditView.changed() doesn't
call self.context.changed(). Who calls it?

Thanks again,
- Shaun

PS I will indeed use formlib eventually, but I want to get just the
workflow down for the prototype I'm writing at the moment.


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


RE: [Zope3-Users] nextURL: add vs edit

2006-02-17 Thread Shaun Cutts


 On Behalf Of Garanin Michael
 What is mixin? Is it content-object or view?

Well, I think in the wider python context mixin is something that you
can use as a base class to extend the functionality of your class,
assuming you provide some standard interface. (e.g. UserDict.DictMixin.)

I'm not sure whether zope uses mixin exactly like this, or whether it
extends mixin for something that you don't have to have in the class
hierarchy, but acts as if it were because of traversal (so perhaps: An
instance is give a special base class of its own that defines
__getattr__ and uses it to search for missing methods in the wider
context? I don't know but I'm a bit wary of the traversals without more
study. They seem to be playing with normal python resolution in a way
that isn't clear to me.)

In this case, I got the term from the ++apidoc++ for the zcml
editform.class attribute:

 A class to provide custom widget definitions or methods to be used by
a
 custom template.

 This class is used as a mix-in class. As a result, it needn't subclass
any
 special classes, such as BrowserView.

And so, my mixin is indeed a view... or at least, it acts like a view.
But I'm a bit hazy on how it is actually constructed and where it is
wrt the EditView object. Is the factory (the class I pass in
editform.class) passed in bases to SimpleViewClass(... ) in
zope.app.forms.browser.editview.EditViewFactory? Then the EditView and
my mixin are both bases of a specially constructed BrowserView
derivative?

That's my best guess without more study of the code.

- Shaun


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