Copying and Pasting SchoolBell objects
======================================

This is, partially, a regression test.  When you use the Zope Management
Interface to copy and paste a SchoolBell object, the object copier provided
with Zope 3 will happily copy relationship links of the object, thus creating
an inconsistency in the internal data structures.  We now have an event
handler that clears all relationship links on copied objects.

Set up
------

We create a SchoolBell instance

    >>> print http(r"""
    ... POST /@@contents.html HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... Content-Length: 81
    ... Content-Type: application/x-www-form-urlencoded
    ... Referer: http://localhost/@@contents.html?type_name=BrowserAdd__schoolbell.app.app.SchoolBellApplication
    ...
    ... type_name=BrowserAdd__schoolbell.app.app.SchoolBellApplication&new_value=frogpond
    ... """)
    HTTP/1.1 303 See Other
    ...

We add a group

    >>> print http(r"""
    ... POST /frogpond/groups/+/addSchoolBellGroup.html%3D HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... Content-Length: 36
    ... Content-Type: application/x-www-form-urlencoded
    ...
    ... field.title=group1&UPDATE_SUBMIT=Add
    ... """)
    HTTP/1.1 303 See Other
    ...

We add a person

    >>> print http(r"""
    ... POST /frogpond/persons/add.html HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... Content-Length: 126
    ... Content-Type: application/x-www-form-urlencoded
    ...
    ... field.title=person1&field.username=person&field.password=&field.verify_password=&field.photo=&group.group1=on&UPDATE_SUBMIT=Add
    ... """)
    HTTP/1.1 303 See Other
    ...

We look at the groups of the person we added

    >>> print http(r"""
    ... GET /frogpond/persons/person HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... """)
    HTTP/1.1 200 Ok
    ...
    ...group1...
    ...

We look at the members of the group

    >>> print http(r"""
    ... GET /frogpond/groups/group1 HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... """)
    HTTP/1.1 200 Ok
    ...
    ...person...

Copying the whole SchoolBell instance
-------------------------------------

If you copy the whole SchoolBell instance, relationships within it are
preserved.

    >>> print http(r"""
    ... POST /@@contents.html HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... Content-Type: application/x-www-form-urlencoded
    ... Content-Length: 44
    ...
    ... ids:list=frogpond&container_copy_button=Copy
    ... """)
    HTTP/1.1 303 See Other
    ...

    >>> print http(r"""
    ... POST /@@contents.html HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... Content-Type: application/x-www-form-urlencoded
    ... Content-Length: 28
    ...
    ... container_paste_button=Paste
    ... """)
    HTTP/1.1 303 See Other
    ...

The group in the new instance has one member

    >>> r = http(r"""
    ... GET /frogpond-2/groups/group1 HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... """)
    >>> print r
    HTTP/1.1 200 Ok
    ...
    ...person...

And it is the right 'person1' (the one in /frogpond-2/ rather than the one
in /frogpond/)

    >>> '/frogpond-2/persons/person' in str(r)
    True
    >>> '/frogpond/' not in str(r)
    True

The person in the new instance has one group

    >>> r = http(r"""
    ... GET /frogpond-2/persons/person HTTP/1.1
    ... Authorization: Basic mgr:mgrpw
    ... """)
    >>> print r
    HTTP/1.1 200 Ok
    ...
    ...group1...

And it is the right 'group1' (the one in /frogpond-2/ rather than the one
in /frogpond/)

    >>> '/frogpond-2/groups/group1' in str(r)
    True
    >>> '/frogpond/' not in str(r)
    True

