Daniel Rusch wrote:
> 
> not sure what you mean by "subobject adding in your __init__ method"????


python prod

def manage_addfooclass():

        x= fooclass()
        id = 1
        self._setObject(id, x)


def fooclass:

        def __init__():

                >>> add subobjects here


seems like you were adding subobjects to your class in your
manage_addfoo when it probably would have been better to add them in
your __init__ method



> Dan
> 
> Kapil Thangavelu wrote:
> 
> > btw daniel,
> >
> > i've looked at some your postings for the day and i thought i should
> > tell you that most of your problems would go away if you did subobject
> > adding in your __init__ method within your class or in the hook method
> > manage_afterAdd within your class. for future reference. You'd get all
> > the benefits of inheritance. Let manage_add to do just that, instantiate
> > and set a instance of your class.
> >
> > Kapil
> >
> > Kapil Thangavelu wrote:
> > >
> > > Daniel wrote
> > >
> > > > I've created a folderish product. When I select that product from the
> > > > available objects list, thus creating an instance of that product, I can
> > > >
> > > > create objects like dtml document and dtml method in the new folderish
> > > > object (very similar to what happens when you instantiate a folder
> > > > object, you can have a dtml method created in the new folder).
> > > >
> > > > The question is why can't I create objects from the Products directory,
> > > > such as Local File System?????
> > > >
> > > > The code below works great, I get a dtml document, two folders each with
> > > >
> > > > a dtml method in them....
> > > > HOW CAN I CREATE A LOCAL FILE SYSTEM OR ANY OTHER OBJECT FROM THE
> > > > PRODUCTS DIRECTORY IN THIS MANAGE_ADD FUNCTION???????
> > > >
> > > > def manage_addSimpleSite(self, id, title='',
> > > >                      createNewFolder=0,
> > > >                      createEditFolder=0,
> > > >                      REQUEST=None):
> > > >     """Add a new SimpleSite object with id *id*.
> > > >
> > > >     If the 'createNewFolder' and 'createEditFolder' parameters are set
> > > > to any true
> > > >     value, an 'New sub Folder' and an 'edit sub Folder' objects are
> > > > created respectively
> > > >     in the new SimpleSite.
> > > >     """
> > > >     ob=SimpleSite()
> > > >     ob.id=id
> > > >     ob.title=title
> > > >     self._setObject(id, ob)
> > > >     try: user=REQUEST['AUTHENTICATED_USER']
> > > >     except: user=None
> > > >     ob.manage_addDTMLDocument(id='index_html', title='')
> > > >     if createNewFolder:
> > > >         if (user is not None) and not (
> > > >             user.has_permission('Add User SimpleSites', self)):
> > > >             raise 'Unauthorized', (
> > > >                   'You are not authorized to add User SimpleSites.'
> > > >                   )
> > > >         ob.manage_addFolder(id='New'+id, title='', createPublic=1)
> > > >     if createEditFolder:
> > > >         if (user is not None) and not (
> > > >             user.has_permission('Add Documents, Images, and Files',
> > > > self)):
> > > >             raise 'Unauthorized', (
> > > >                   'You are not authorized to add DTML Documents.'
> > > >                   )
> > > >         ob.manage_addFolder(id='Edit'+id, title='', createPublic=1)
> > > >     if REQUEST is not None:
> > > >         return self.manage_main(self, REQUEST, update_menu=1)
> > > >
> > >
> > > a couple of things.
> > >
> > > A. you're not being blackballed. when you're posting to the list its
> > > hard to help without specifics. you're posting above, would be better
> > > with a traceback of code that does attempt to instantiate a product.
> > > which leads to
> > >
> > > B. how are you attempting to instantiate your other products. example
> > > code of what you're trying to do would be helpful. are you doing it the
> > > same as adding folders like above... i have no idea...
> > >
> > > C. seems like you're doing this in python. the code below should work
> > > fine.
> > >
> > > from Products import LocalFS
> > >
> > > in manage_add:
> > >
> > >         id = 'foo'
> > >         ob2 = LocalFS.LocalFS(id) # check the exact calls to __init__ in
> > > LocalFS
> > >         id2 = 'foo2'
> > >
> > >         ob = yourproduct(id2)
> > >         ob._setObject(id , ob2)
> > >
> > > in  __init__ or manage_afterAdd
> > >
> > >         id ='foo'
> > >         ob = LocalFS.LocalFS(id)
> > >         self._setObject(id, ob)
> > >
> > > _______________________________________________
> > > Zope maillist  -  [EMAIL PROTECTED]
> > > http://lists.zope.org/mailman/listinfo/zope
> > > **   No cross posts or HTML encoding!  **
> > > (Related lists -
> > >  http://lists.zope.org/mailman/listinfo/zope-announce
> > >  http://lists.zope.org/mailman/listinfo/zope-dev )
> >
> > _______________________________________________
> > Zope maillist  -  [EMAIL PROTECTED]
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to