[Zope] - Toy Product problems

Christopher G. Petrilli petrilli@amber.org
Fri, 1 Jan 1999 22:50:14 -0500


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