Created
April 27, 2016 16:02
-
-
Save ale-rt/3c7741dd2013f364ac8370bc07273727 to your computer and use it in GitHub Desktop.
bin/instance run this script to dump your Plone site into an a folder
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 | |
""" | |
Dump looks like this: | |
/tmp/content_Plone_2016-04-27-16-44-35/ | |
└── 0 | |
├── 1.json | |
├── 2.json | |
├── 3.json | |
├── 4.json | |
├── 5.json | |
└── 6.json | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment