Markus Leist wrote:
i have created a thread in my zope3-application like the 

What i want to do: "fake" a request-context to get a local Utility (via Sitemanager) configured in ZODB and call some methods which will
change some object-attributes in ZODB.

You'll have to open a new connection to the database in the thread and get the root object from it (you'll have to give the thread a reference to the database, which can be accessed from any persistent object thru obj._p_jar, IIRC):

  conn =
  root = conn.root()
  root_folder = root['Application']

Now you can traverse to the site that contains the local utilities (unless that's the root_folder) and make the current active site (current = for this particular thread):

  from import setSite
  site = root_folder['path']['to']['the']['site']

Now do your component lookups, object modifications, etc. Don't forget to commit the transaction at the end:

  import transaction

and close the connection:


-- -- Professional Zope documentation and training

Zope3-users mailing list

Reply via email to