Hi there, I'm stil trying to build my personal Folder product, let's call it "minimal" (ok, ok, I'm working on tutorials :-) I was trying to subclass ObjectManager, but then I've been told to subclass Folder insted since it subclasses ObjectManager itself (and it does, i checked). I'm still trying to give my product a "Folder" feel, that is, I want to be able to click on in and "enter" it, and see what's inside it (that is the standard Content view of a folder). Now what happens is this: let my "minimal" object id be "abc", and let it be contained by the "Test" folder. when I click on it the url becomes http://.../Test/abc so it looks like I'm inside it, but I still see the "Test" folder content, that is I still see the "abc" object. In other words it looks like if the "abc" object contains itself. If I click on it again the url becomes http://.../Test/abc/abc and then abc/abc/abc and so on. Why can't I "see" inside it and can't put other objects in it? Should I include something special? Should I put something particular in the manage_options? I'm sorry but I couldn't find anything in the docs :-( and that's question one. then, why (see code below) do I have to subclass the Implicit class too?? if I don't do it I get: Exception type: TypeError Exception value: base is not a class object Traceback (innermost last): File /usr/local/Zope-2.4.1-linux2-x86/lib/python/App/RefreshFuncs.py, line 255, in performSafeRefresh File /usr/local/Zope-2.4.1-linux2-x86/lib/python/App/RefreshFuncs.py, line 242, in performRefresh File /usr/local/Zope-2.4.1-linux2-x86/lib/python/OFS/Application.py, line 756, in reimport_product File /usr/local/Zope-2.4.1-linux2-x86/lib/python/OFS/Application.py, line 558, in import_product File /usr/local/zope/lib/python/Products/minimal/__init__.py, line 1, in ? File /usr/local/zope/lib/python/Products/minimal/minimal.py, line 17, in ? TypeError: base is not a class object But if I subclass Folder that subclasses ObjectManager that subclasses Aquisition.Implicit, why should I subclass Implicit again??? These Python-Zope products are pretty complicated, aren't they? ok, this is my code: # minimal.py from OFS import Folder from Acquisition import Implicit from Globals import DTMLFile class minimal(Implicit, Folder): "minimal object" meta_type='minimal' meta_types=() index_html=DTMLFile('www/index_html', globals()) manage_options=( {'label': 'View', 'action': 'index_html'}, ) def __init__(self, id): "initialize a new instance of minimal" self.id=id def manage_addMinimal(self, id, RESPONSE=None): "Add a minimal to a folder" self._setObject(id, minimal(id)) RESPONSE.redirect('index_html') manage_addMinimalForm=DTMLFile('www/manage_addMinimalForm', globals()) other file: # __init__.py import minimal def initialize(context): """Initialize the minimal product this makes the object appear in the product list""" context.registerClass( minimal.minimal, constructors = ( minimal.manage_addMinimalForm , minimal.manage_addMinimal) ) I really thank you all for the help. The zope community is just GREAT. I hope one day I'll be able to give back to newbies what I'm learning now :-) |G|
from OFS import Folder
d'oh! I believe you meant: from OFS.Folder import Folder
class minimal(Implicit, Folder):
...and it's whinging here 'cos you're trying to subclass a module not a class ;-) Other than that, you don't need that Implicit there.
meta_types=() index_html=DTMLFile('www/index_html', globals()) manage_options=( def __init__(self, id):
BTW, for a _really_ minimal product, none of the above are necessary ;-) cheers, Chris
Chris Withers (09/09/01, 09:22) "Re: [Zope] Now it's a "Folder" class...": CW| > from OFS import Folder CW| CW| d'oh! CW| CW| I believe you meant: CW| CW| from OFS.Folder import Folder Great, you were right. Now I just subclass "Folder" and it seems to work, I can actually go "inside" my object. Thanks Chris!! |G|
Well _somebody_ is working on another How-To, and is guessing that you will like this the class below: I don't remember if it runs in this version, but I believe so. Anyway it should get you a step further Regards Max M ------------ from OFS import SimpleItem, ObjectManager from OFS.ObjectManager import ObjectManager from Globals import DTMLFile import Products class minimalOM(ObjectManager, SimpleItem.SimpleItem): """ A minimalOM product """ meta_type = 'minimalOM' manage_options = ObjectManager.manage_options + ( {'label': 'Properties', 'action': 'manage_editForm',}, {'label': 'View', 'action': 'index_html',}, ) __ac_permissions__ = ObjectManager.__ac_permissions__ + ( ('View', # label ('index_html',), # methods ('Anonymous', 'Manager'), # roles ), ('Change minimalOM', ('manage_editAction', 'manage_editForm'), ('Manager',) ), ('Add minimalOM', ('manage_addminimalOMAction', 'manage_addminimalOMForm'), ('Manager',) ), ) def all_meta_types(self): """ What types can you add to this objectManager? """ allowedMetaTypes = ('DTML Method', 'DTML Document', 'minimal') result = [] for metaType in Products.meta_types: if metaType['name'] in allowedMetaTypes: result.append(metaType) return result def __init__(self, id, title): "Inits the product with default values" self.id = id self.title = title def manage_editAction(self, title, RESPONSE=None): "Changes the product values" self.title = title self._p_changed = 1 RESPONSE.redirect('manage_editForm') def editAction(self, title, RESPONSE=None): "Changes the product values" self.title = title self._p_changed = 1 RESPONSE.redirect('manage_editForm') ########################## # The web pages that shows content. Put your own in the www folder. # Used to view content of the object index_html = DTMLFile('www/index_html', globals()) # Edit the content of the object manage_editForm = DTMLFile('www/manage_editForm', globals()) # Edit the content of the object edit = DTMLFile('www/edit', globals()) ########################## # constructor pages. Only used when the product is added to a folder. def manage_addminimalOMAction(self, id='minimalOM', title='Title here', REQUEST=None): "Add a minimalOM to a folder." self._setObject(id, minimalOM(id, title)) if REQUEST is not None: return self.manage_main(self, REQUEST) # Get user input from this form manage_addminimalOMForm = DTMLFile('manage_addminimalOMForm', globals())
aaa@simplesky.com writes:
.... I'm still trying to give my product a "Folder" feel, that is, I want to be able to click on in and "enter" it, and see what's inside it (that is the standard Content view of a folder).
Now what happens is this: let my "minimal" object id be "abc", and let it be contained by the "Test" folder. when I click on it the url becomes http://.../Test/abc Where do you click on it?
If you get this URL, then you are looking in fact at "http://.../Test/abc/index_html" which may be acquired.... To see the content view, you should see the URL <http://.../Test/abc/manage> or <http://.../Test/abc/manage_workspace>.
so it looks like I'm inside it, but I still see the "Test" folder content, that is I still see the "abc" object. In other words it looks like if the "abc" object contains itself. If I click on it again the url becomes http://.../Test/abc/abc and then abc/abc/abc and so on. That's normal resolution of relative URL's, explained e.g. in
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
Why can't I "see" inside it and can't put other objects in it? Depending on where you click...
You should not get the URL given above - as explained above. If you click on the management interface, the URL's you see for entering an instance of your product should not depend on your product at all... That makes an answer to your problem a bit difficult. We need more information... Dieter
participants (4)
-
aaa@simplesky.com -
Chris Withers -
Dieter Maurer -
Max M