[Zope] - Toy Product problems

Paul Everitt Paul@digicool.com
Sat, 2 Jan 1999 10:25:45 -0500


As everyone knows, I'm a dunce at programming and usually make things
worse when I intervene.  But...I suggest you stay in Python and try to
do the operations.  Perhaps also use the debugger.  You'll never find
this error by publishing the object and using the web browser to debug
it.

I suspect that some state is missing and the object is having trouble
being reincarnated.  Try sitting in Python and grabbing the instance you
created, perhaps doing an str on it to make it cough up some state.

Then try walking up to the manage_main operation in the debugger.

--Paul

> -----Original Message-----
> From: Christopher G. Petrilli [mailto:petrilli@amber.org]
> Sent: Friday, January 01, 1999 10:50 PM
> To: zope@zope.org
> Subject: [Zope] - Toy Product problems
> 
> 
> So I've got this product I'm working on... to manage all external
> references on a web site... I was having all kinds of problems, and
> here's the absolutely stripped down minimum, no frills, no real major
> functionality version of it, and here's the symptoms of it:
> 
> 	* Can't view manage_main, get:
> 	  The parameter, <em>trueself</em>, was omitted from the
> 	  request.
> 
> 	  Traceback:
> 	  Traceback (innermost last):
> 	    File
> 	    
> /home/petrilli/src/Zope-1.9.0-src/lib/python/ZPublisher/Publish.py,
> 	    line 880, in publish_module
> 	      File
> 	      
> /home/petrilli/src/Zope-1.9.0-src/lib/python/ZPublisher/Publish.py,
> 	      line 589, in publish
> 	          (Info: /blah/manage_main)
> 		    File
> 		    
> /home/petrilli/src/Zope-1.9.0-src/lib/python/ZPublisher/Publish.py,
> 		    line 288, in badRequestError
> 		    BadRequest: (see above)
> 	* Display in Folder listing is bogus:
> 
> 	      <? icon> Zope () 
> 
> 	  Even though I gave it an id and title...
> 
> Any hints would be fine, this is just obviously a stupidity 
> on my part,
> but hey, someone's gotta make the dumb mistakes!  Thanks Amos for the
> tutorial, but I swear I followed it! :-)
> 
> Here's hte code, for it:
> 
> 
> #
> # *   * **** *
> # *   * *  * *     TRACKER
> # *   * ***  *
> #  ***  *  * **** 
> #
> # Copyright (C) 1998 Christopher G. Petrilli
> # All Rights Reserved
> #
> # Contact: petrilli@amber.org
> #
> 
> """URL Tracker - A Zope Product
> 
> URL Tracker allows for the management of external references 
> from a Zope
> system. It keeps track of when the URL was inserted, when it was last
> verified, it's status, and it's representation."""
> 
> from Globals import HTMLFile, MessageDialog, Persistent
> import Acquisition
> import AccessControl
> import OFS
> 
> class URL:
>     """A Uniform Resource Locator"""
> 
>     icon = "misc_/URLTracker/url"       # Icon to use for display
> 
>     meta_type = "URL"
> 
>     # Tabs for the management of the object
>     manage_options = (
>         {"label": "Properties",     "action": "manage_main"  },
>         {"label": "View",           "action": ""             },
>         {"label": "Validate",       "action": ""             },
>         {"label": "Security",       "action": "manage_access"},
>         )
> 
>     # Security permissions
>     __ac_permissions__ = (
>         ("View management screens", ("manage_tabs", "manage_main")),
>         ("Change permissions",      ("manage_access",            )),
>         ("Change URL",              ("manage_edit",), ("Manager",)),
>         ("Validate",                ("manage_validate",          )),
>         ("View",                    ("",                         )),
>         )
> 
>     # Set up the HTMLFiles
>     manage_main = HTMLFile("editURL", globals())
>     index_html = HTMLFile("index_html", globals())
>     
>     def __init__(self, id, title, url, autovalidate):
>         self.id = id
>         self.title = title
>         self.url = url
>         self.autovalidate = autovalidate
>         self.validated = None           # Last occasion validated
>         self.status = None              # Status of validation
> 
>     def __str__(self):
>         """String representation of the object when called by 
> #var in DTML"""
>         return '<A HREF="' + self.url + '>'
> 
>     # <!--#ref urlname--> or <!--#ref urlname "inside the anchor"-->
> ##    def __dtml_ref(self, arg=None):
> ##        """Proposed DTML #ref keyword"""
> ##        tmp = '<A HREF="' + self.url + '>'
> ##        if arg:
> ##            tmp = tmp + arg + '</A>'
> ##        return tmp
>         
>     def validate(self):
>         """Eventually this will do something, but not quite yet."""
>         pass
> 
>     def manage_edit(self, title, url, autovalidate, REQUEST=None):
>         """Edit the URL's characteristics
> 
>         title - string title
>         url - string representing the URL
>         autovalidate - boolean as to whether to validate 
> automatically"""
> 
>         self.title = title
>         self.url = url
>         self.autovalidate = autovalidate
> 
>         if REQUEST is not None:
>             return MessageDialog(
>                 title = "Edited",
>                 message = "<strong>%s</strong> has been 
> edited." % self.id,
>                 action = "./manage_main",
>                 )
> 
> # Form for creation
> addURLForm = HTMLFile("addURL", globals())
> 
> def addURL(self, id, title, url, autovalidate, REQUEST=None):
>     """Create a new URL entry and install into the parent folder
> 
>     The argument 'self' is bound to the current folder."""
> 
>     newURL = URL(id, title, url, autovalidate)
>     self._setObject(id, newURL)
> 
>     if REQUEST is not None:
>         return self.manage_main(self, REQUEST)
> -- 
> | Christopher Petrilli
> | petrilli@amber.org
> 
>