[Zope3-dev] Back to Job editing

Jeffrey P Shell jeffrey@cuemedia.com
Tue, 03 Sep 2002 12:32:42 -0600


A fairly common Zope 2 idiot^Hm is for classes to define a catch-all 'edit'
method to batch-update object attributes.  In the PythonProgrammerTutorial
'Contact' example, this idiom seems to persist:

class IContact(IContactInfo):
    "Provides the ability to change contact information."

    def update(first, last, email, address, pc):
        """Modifies contact data
        
        'None' values are ignored.
        """

Which makes a degree of sense - it's easier to protect a single 'update'
method than to allow direct attribute setting.  But, with Schema and Python
2.2+ Properties, is it still the right way?  It feels more like something
that would go on an Adapter / Edit View, since targets of web forms, RPC
calls, etc..., have an easier time calling a single 'update' method that
doesn't make as much sense on a fundamental business, er, content component
except as a convenience function (and again - that convenience seems to
exist more for security/web situations).

I'm bringing this up because the current JobBoardEx package doesn't allow
editing of single Jobs, which I was trying to make a sortof third-party edit
view for as a test/example of how to do such things in Zope 3.  Since
there's no convenient 'update()' method for Job instances, and the untrusted
code of my new JobEditView can't set attributes, it doesn't work.

I'm not sure what the best practice is, or should be.

-- 
Jeffrey P Shell 
www.cuemedia.com