Plone 3.1.2 - TypeError in ATDocument.getText() method
Question: My task is to unload content from a Plone 3.1.2 website and load information
about the content to an SQL database + file system

I've recreated the website, got access to ZODB and recreated object and folder
structure. I am also able to read properties of folders, files and documents.
I can't get the .getText() method of ATDocument to work. The Traceback looks
like this:

Traceback (most recent call last):

    
    
      File "C:\Users\jan\Eclipse_workspace\Plone\start.py", line 133, in ? 
        main() 
      File "C:\Users\jan\Eclipse_workspace\Plone\start.py", line 118, in main 
        print dokument.getText() 
      File "e:\Program Files\Plone 3\Data\Products\Archetypes\ClassGen.py", line 54, in generatedAccessor
      File "e:\Program Files\Plone 3\Data\Products\Archetypes\BaseObject.py", line 828, in Schema 
    TypeError: ('Could not adapt', <ATDocument at /*object_path*>, <InterfaceClass Products.Archetypes.interfaces._schema.ISchema>) 
    

I suspect that there is a problem with connecting the object to interface
ISchema, but I've never worked with Plone before and don't know it's object
model.

Any suggestions what might be wrong or missing, how can I fix it and/or what
to do next? I suspect that I have to connect ISchema interface class with this
object somehow, but have no idea where to start. Any suggestions?

I'll be greatful for any help since I'm stuck for 2 days now and not moving
forward.

I know nothing about ZCML format or how to edit it. Because after `>>> print
dokument.getText()` in debug mode the script jumps to `makeMethod()` method in
Generator class I assume that the script doesn't execute `.getText()` but
tries to create this method instead.

Since `inspect.getmembers(dokument)` returns a `getText()` method I'm really
confused. Do you know in which ZCML file might be related to ATDocument class?
Or where can I look for any information on this subject?

My start.py file doesn't do much else than the following imports:

    
    
    from ZODB.FileStorage import FileStorage
    from ZODB.DB import DB
    from OFS.Application import Application
    from BTrees import OOBTree
    from Products.CMFPlone.Portal import PloneSite
    

then it gets access to dokument object and tries to execute `.getText()`

Edit 213-03-26 15:27 (GMT):

About the .zcml files The site I've received was 3 folders: Products
(extracted to `\Plone 3\Data`), lib and package-includes.

Inside the lib there is python folder containing 3 subfolders: 'common', 'abc'
and 'def' (names changed not to release client's information). Each of these
subfolders contains a configure.zcml file, one of these also includes
override.zcml file.

In the folder package-includes there are 4 files, each of them 1 line long.
They contain the following lines:

    
    
    <include package="abc" file="configure.zcml" />
    <include package="def" file="overrides.zcml" />
    <include package="common" file="configure.zcml" />
    <include package="def" file="configure.zcml" />
    

These zcml files are not copied at the moment. Where can I copy these to have
these imported?


Answer: You are missing component registrations, usually registered when loading the
ZCML files in a site.

You want to end up with the possibility to run `bin/instance run
yourscript.py` instead, which leaves all the tedious site and ZCML loading to
Zope.

Once you have that running reliably, you can then access the site in a script
that sets up the local component manager and a security manager:

    
    
    from zope.app.component.hooks import setSite
    from Testing.makerequest import makerequest
    from AccessControl.SecurityManagement import newSecurityManager
    
    site_id = 'Plone'     # adjust to match your Plone site object id.
    admin_user = 'admin'  # usually 'admin', probably won't need adjusting
    app = makerequest(app)
    site = app[site_id]
    setSite(site)
    user = app.acl_users.getUser(admin_user).__of__(site.acl_users)
    newSecurityManager(None, user)
    
    # `site` is your Plone site, now correctly set up
    

Save this script somewhere, and run it with:

    
    
    bin/instance run path/to/yourscript.py
    

