[Zope] Creating folders based on a skeleton, programatically?

Phil Harris phil.harris@zope.co.uk
Mon, 24 Jan 2000 10:28:08 -0000


Hi all,

I'm trying to create a user's folder programatically.

This is quite easy, but I want to then create the contents based on the
contents of another folder ('skel').

Once the user folder is created I'm trying to use manage_copyObjects and
then manage_pasteObjects to accomplish this.

The Folder structure is like this:

Root
  +-World
    +-skel

addUserForm looks like:

<!-- begin dtml -->
<dtml-var standard_html_header>
<P>To add a new user, enter the name, password, confirmation and roles for
the new user and click &quot;Add&quot;. <br>
<EM>Domains</EM> is an optional list of domains from which the user is
allowed to login.
</P>

<FORM ACTION="addUser" METHOD="POST">
<TABLE>
<TR><Th align="right">Name:</Th><TD VALIGN="TOP"><INPUT TYPE="TEXT"
NAME="name" SIZE="20"></TD></TR>
<TR><Th align="right">Password:</TD><TD VALIGN="TOP"><INPUT TYPE="PASSWORD"
NAME="password" SIZE="40"></TD></TR>
<TR><Th align="right">(Confirm):</Th><TD VALIGN="TOP"><INPUT TYPE="PASSWORD"
NAME="confirm" SIZE="40"></TD></TR>
<TR><TD VALIGN="TOP"></TD><TD VALIGN="TOP"><INPUT TYPE="SUBMIT"
NAME="submit" VALUE="Add"></TD></TR>
</TABLE>
</FORM>
<dtml-var standard_html_footer>
<!-- end dtml -->

There is then an external method ('addUser') that creates the user (works
ok), creates the user's folder (works ok) and then attempts to create the
content based on the contents of 'skel'. This external method has these
lines in (amongst others):

self.manage_addFolder(id=username,title='',createPublic=0,createUserF=0)
o=getattr(self,username)
o.manage_pasteObjects(o.skel.manage_copyObjects(o.skel.objectIds()))

So calling the addUserForm like http://localhost:8080/World/addUserForm
calls addUser with the relevant details in the REQUEST.

However when the line above doing the copy tries to execute I get this error
message:

<!-- begin error message -->
One or more items referred to in the clipboard data was not found. The item
may have been moved or deleted after you copied it.
<!-- end error message-->

with this traceback in the source of the error page:

Traceback (innermost last):
  File C:\PROGRA~1\zope\lib\python\ZPublisher\Publish.py, line 214, in
publish_module
  File C:\PROGRA~1\zope\lib\python\ZPublisher\Publish.py, line 179, in
publish
  File C:\PROGRA~1\zope\lib\python\Zope\__init__.py, line 202, in
zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File C:\PROGRA~1\zope\lib\python\ZPublisher\Publish.py, line 165, in
publish
  File C:\PROGRA~1\zope\lib\python\ZPublisher\mapply.py, line 160, in mapply
    (Object: addUser)
  File C:\PROGRA~1\zope\lib\python\ZPublisher\Publish.py, line 102, in
call_object
    (Object: addUser)
  File
C:\PROGRA~1\zope\lib\python\Products\ExternalMethod\ExternalMethod.py, line
248, in __call__
    (Object: addUser)
    (Info: ((&lt;Folder instance at 08B10700&gt;,
&lt;h3&gt;form&lt;/h3&gt;&lt;table&gt;&lt;tr valign=&quot;top&quot;
&lt;/tr&gt;

<snip lot's of request detail you don't really need to see>

&lt;/table&gt;, ZServerHTTPResponse('')), {}, (None, None)))
  File C:\PROGRA~1\zope\Extensions\add_User.py, line 42, in add_User
    (Object: ElementWithAttributes)
  File C:\PROGRA~1\zope\lib\python\OFS\CopySupport.py, line 198, in
manage_pasteObjects
    (Object: ElementWithAttributes)
Copy Error: (see above)

Any body got any ideas?

TIA

Phil
phil.harris@zope.co.uk