Yahtzee!

On 2/27/06, Gary Poster <[EMAIL PROTECTED]> wrote:

> > Damn, I still can't get this working right after following all of the
> > instructions here.  I can successfully stash the refering url in a
> > hidden form, but it's not showing up in my request.
>
> I can think of two possible things.
>
> One is that you are maybe getting a form validation error and then
> pressing Apply, or that you are using a widget that redraws the screen.
>
> Another is that we might have a bug that makes form variables be
> stomped on by header names. :-(

Gary is a very smart.

> def referer(self):
>      return self.request.form.get('HTTP_REFERER') or
> self.request.getHeader('HTTP_REFERER')

This does not work... same behaviour as previous.

> Then if that doesn't work, try changing it to
>
> def referer(self):
>      return self.request.form.get('referrer') or
> self.request.getHeader('HTTP_REFERER')
>
> and changing your template to have
> >    <input type="hidden" name="referrer" value=""
> >         tal:attributes="value view/referer" />
>
> (Sadly, the spec made a spelling error with "referer". :-) )

Yahtzee!  This works great.  So I guess form names are being stomped
by header names.

Thank you so much, Gary.  Let me know if I should do anything to
follow up on this bug.

For posterity, here's my setup.

from zope.formlib import form
from zope.app.pagetemplate import ViewPageTemplateFile

class PitcherEditForm(form.EditForm):
    form_fields = form.Fields(interfaces.IPitcher).select('Last',
'First', 'ERA')

    base_template = form.EditForm.template
    template = ViewPageTemplateFile('editTemplate.pt')

    def referer(self):
        return self.request.form.get('referrer') or
self.request.getHeader('HTTP_REFERER')

    def render(self):
        if self.errors is None or self.errors:
            return super(PitcherEditForm, self).render()
        # DO NOT USE HTTP_REFERER AS A FORM NAME
        #redirectTo=self.request.form.get('HTTP_REFERER', '..')
        redirectTo=self.request.form.get('referrer', '..')
        self.request.response.redirect(redirectTo)

<editTemplate.pt>

<div metal:use-macro="view/base_template/macros/main" >
  <div metal:fill-slot="extra_info">
   <input type="hidden" name="referrer" value=""
        tal:attributes="value view/referer" />
  </div>
</div>
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to