[Zope-dev] Copy and paste is not working in custom folder product

Martijn Faassen faassen@vet.uu.nl
Fri, 26 Nov 1999 04:30:01 +0100


Evan Simpson wrote:
> Martijn Faassen wrote:
> 
> > Thanks for this clue! I don't know what to do now, though. My .dtml files
> > don't reside in subdirectories. Though it's very well possible it's due to
> > some of the other odd stuff I do. :) How'd you change the way you loaded
> > your .dtml files?
> 
> I changed
> 
> manage_addPythonMethodForm=HTMLFile('www/methodAdd', globals())
> 
> to
> 
> _www = os.path.join(package_home(globals()), 'www')
> manage_addPythonMethodForm=HTMLFile('methodAdd', _www)
> 
> All I can figure is that loading the HTMLFile with a pathname instead of a
> basename somehow caused the problem.

The exact equivalent can't be happening in my code right now; everything's
in one directory right now.

I *do* mess with meta_types, though. When I register a SimpleItem derived
class with my Folderish object, I do an ugly hack to manually add it to 
its meta_types:

# Form is the class of my Folderish object (deriving from ObjectManager)
# fieldname is the meta_type of the field object I want to addable to
# these forms

# add this as an addable field to the form
# for some reason we must use this tuple adding,
# as setting meta_types to an empty list in Form
# does not appear work; meta_types always seems to be a tuple.
Form.meta_types = Form.meta_types +\
    ({ 'name': fieldname,
       'action': 'manage_add%sForm' % fieldname },
    )
    
I imagine this kind of hack could wreck things. This is another hack:

# add manage_add method for this field to the Form class
# use FormHack to create the right add form
setattr(Form,
	'manage_add%sForm' % fieldname,
	FormHack(fieldname))

Where FormHack is a class I use instead of HTMLFile(). The FormHack instance
simply gives back the HTML I want when called. I reported the weird grief
HTMLFile() gave me earlier on the list. Anyway, this hack is another
suspect. And there are other tricks I've used to shield my code from Zope's
machinery.

Perhaps this has given anybody any clues as to my problems?

Regards,

Martijn