Guest User

Untitled

a guest
May 5th, 2015
199
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from ZEO.ClientStorage import ClientStorage
  2. from ZODB import DB
  3. from Persistence import Persistent
  4.  
  5. import transaction, logging
  6.  
  7. from OFS.Image import Image
  8. from OFS.Image import File
  9. from OFS.Folder import Folder
  10.  
  11. import magic
  12. import os.path, time
  13.  
  14. # Access control
  15.  
  16. import zope
  17. from AccessControl.SecurityManagement import newSecurityManager
  18. from AccessControl.SecurityManager import setSecurityPolicy
  19. from Testing.makerequest import makerequest
  20. from Products.CMFCore.tests.base.security import PermissiveSecurityPolicy, OmnipotentUser
  21.  
  22. def spoofRequest(app):
  23.     """
  24.    Make REQUEST variable to be available on the Zope application server.
  25.  
  26.    This allows acquisition to work properly
  27.    """
  28.     _policy=PermissiveSecurityPolicy()
  29.     _oldpolicy=setSecurityPolicy(_policy)
  30.     newSecurityManager(None, OmnipotentUser().__of__(app.acl_users))
  31.     return makerequest(app)
  32.  
  33. logging.basicConfig()
  34. storage=ClientStorage(('192.168.10.38',9999))
  35. db=DB(storage)
  36. conn=db.open()
  37. app=conn.root()['Application']
  38. path = "/dummy/renametest1"
  39. app = spoofRequest(app)
  40. obj = app.unrestrictedTraverse(path, None)
  41.  
  42. old_id = obj.getId()
  43. new_id = old_id + "-new"
  44.  
  45. obj.aq_parent.manage_renameObjects([old_id], [new_id], app.REQUEST)
  46.  
  47. transaction.commit()
  48.  
  49. conn.close()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×