[Zope] Product creation question

Daniel Rusch drusch@globalcrossing.com
Wed, 23 Aug 2000 13:41:38 -0500


--------------1A6E6CEE7895A086A0EC9FE9
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I've created a product called BasicDocument. I've installed it and it
works great.

I've also created a folderish product. Installed. When a user selects
that product from the
 available objects list, thus creating an instance of that product, they
have an option to
 create sub folders which contain objects like dtml documents, dtml
methods, and my BasicDocument product
(very similar to what happens when you instantiate a folder object, you
can have a dtml method created in the new folder).

I am able to have the manage_addSimpleSite function to create
DTMLDocument, DTMLMethod and Folder objects but I am unable to have the
function create BasicDocuments (which live in the Products directory)
additionally, I am unbale to it create any Products 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???????

ob.manage_addBasicDocument(id='index_html', title='')    <--
THIS LINES GENERATES AN ERROR: AttributeError: manage_addBasicDocument

ref the code below.

Please reply all if you are responding from the dev list as I usually
don't monitor the dev list.
Thanks,

Dan

 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_addBasicDocument(id='index_html', title='')    <--
THIS LINES GENERATES AN ERROR: AttributeError: manage_addBasicDocument
     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

--------------1A6E6CEE7895A086A0EC9FE9
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I've created a product called BasicDocument. I've installed it and it works
great.
<p>I've also created a folderish product. Installed. When a user selects
that product from the
<br>&nbsp;available objects list, thus creating an instance of that product,
they have an option to
<br>&nbsp;create sub folders which contain objects like dtml documents,
dtml methods, and my BasicDocument product
<br>(very similar to what happens when you instantiate a folder object,
you can have a dtml method created in the new folder).
<br>&nbsp;
<br>I am able to have the manage_addSimpleSite function to create DTMLDocument,
DTMLMethod and Folder objects but I am unable to have the function create
BasicDocuments (which live in the Products directory) additionally, I am
unbale to it create any Products from the Products directory,
<br>such as Local File System?????
<br>&nbsp;
<br>&nbsp;The code below works great, I get a dtml document, two folders
each with a dtml method in them....
<br>&nbsp;
<p>&nbsp;HOW CAN I CREATE A LOCAL FILE SYSTEM OR ANY OTHER OBJECT FROM
THE
<br>&nbsp;PRODUCTS DIRECTORY IN THIS MANAGE_ADD FUNCTION???????
<p>ob.manage_addBasicDocument(id='index_html', title='')&nbsp;&nbsp;&nbsp;
<font size=+1>&lt;-- THIS&nbsp;LINES&nbsp;GENERATES&nbsp;AN&nbsp;ERROR:
AttributeError: manage_addBasicDocument</font><font size=+1></font>
<p><font size=+1>ref the code below.</font><font size=+1></font>
<p><font size=+1>Please reply all if you are responding from the dev list
as I usually don't monitor the dev list.</font>
<br><font size=+1>Thanks,</font><font size=+1></font>
<p><font size=+1>Dan</font>
<br>&nbsp;
<br>&nbsp;def manage_addSimpleSite(self, id, title='',
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
createNewFolder=0,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
createEditFolder=0,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
REQUEST=None):
<br>&nbsp;&nbsp;&nbsp;&nbsp; """Add a new SimpleSite object with id *id*.
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp; If the 'createNewFolder' and 'createEditFolder'
parameters are set
<br>&nbsp;to any true
<br>&nbsp;&nbsp;&nbsp;&nbsp; value, an 'New sub Folder' and an 'edit sub
Folder' objects are
<br>&nbsp;created respectively
<br>&nbsp;&nbsp;&nbsp;&nbsp; in the new SimpleSite.
<br>&nbsp;&nbsp;&nbsp;&nbsp; """
<br>&nbsp;&nbsp;&nbsp;&nbsp; ob=SimpleSite()
<br>&nbsp;&nbsp;&nbsp;&nbsp; ob.id=id
<br>&nbsp;&nbsp;&nbsp;&nbsp; ob.title=title
<br>&nbsp;&nbsp;&nbsp;&nbsp; self._setObject(id, ob)&nbsp;&nbsp;&nbsp;&nbsp;
try: user=REQUEST['AUTHENTICATED_USER']
<br>&nbsp;&nbsp;&nbsp;&nbsp; except: user=None
<br>&nbsp;&nbsp;&nbsp;&nbsp; ob.manage_addBasicDocument(id='index_html',
title='')&nbsp;&nbsp;&nbsp; <font size=+1>&lt;-- THIS&nbsp;LINES&nbsp;GENERATES&nbsp;AN&nbsp;ERROR:
AttributeError: manage_addBasicDocument</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp; ob.manage_addDTMLDocument(id='index_html',
title='')
<br>&nbsp;&nbsp;&nbsp;&nbsp; if createNewFolder:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (user is not None)
and not (
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
user.has_permission('Add User SimpleSites', self)):
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
raise 'Unauthorized', (
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'You are not authorized to add User SimpleSites.'
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ob.manage_addFolder(id='New'+id,
title='', createPublic=1)
<br>&nbsp;&nbsp;&nbsp;&nbsp; if createEditFolder:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (user is not None)
and not (
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
user.has_permission('Add Documents, Images, and Files',
<br>&nbsp;self)):
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
raise 'Unauthorized', (
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'You are not authorized to add DTML Documents.'
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ob.manage_addFolder(id='Edit'+id,
title='', createPublic=1)
<br>&nbsp;&nbsp;&nbsp;&nbsp; if REQUEST is not None:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.manage_main(self,
REQUEST, update_menu=1</html>

--------------1A6E6CEE7895A086A0EC9FE9--