Created
April 27, 2016 16:00
-
-
Save ale-rt/ffdf2ad7ec7a6c6eee614cb3d984498c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
from AccessControl.SecurityManagement import newSecurityManager | |
from AccessControl.SecurityManager import setSecurityPolicy | |
from collective.jsonify.export import export_content | |
from logging import DEBUG | |
from logging import getLogger | |
from Products.CMFCore.tests.base.security import OmnipotentUser | |
from Products.CMFCore.tests.base.security import PermissiveSecurityPolicy | |
from Testing.makerequest import makerequest | |
logger = getLogger(__name__) | |
logger.setLevel(DEBUG) | |
def spoofRequest(app): | |
""" | |
Make REQUEST variable to be available on the Zope application server. | |
This allows acquisition to work properly | |
""" | |
_policy = PermissiveSecurityPolicy() | |
_oldpolicy = setSecurityPolicy(_policy) | |
newSecurityManager(None, OmnipotentUser().__of__(app.acl_users)) | |
return makerequest(app) | |
def main(app): | |
''' | |
print some data | |
''' | |
# Enable Faux HTTP request object | |
app = spoofRequest(app) | |
data = export_content( | |
app.Plone, | |
basedir='/tmp', # export directory | |
extra_skip_classname=['ATTopic'], | |
batch_start=0, | |
batch_size=5000, | |
) | |
logger.warning(data) | |
if "app" in locals(): | |
main(app) # noqa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment