Maybe you knew this, but I just found out and I had to write it… otherwise I’ll forget it.
First start a plone instance in debug mode:
-
$ bin/instance debug
-
Starting debugger (the name “app” is bound to the top-level Zope object)
Now you have your python shell to play!
First of all you need a user, so let’s try the admin user:
-
from AccessControl.SecurityManagement import newSecurityManager
-
user = app.acl_users.authenticate(“admin”, “admin”, None)
-
newSecurityManager(None, user)
As you probably guessed the first “admin” is the username, and the second one the password.
OK, now we have enough permissions to create our content let’s move on, imagine you have a
plone site called “development” and a folder called “test” in it.
-
container = app.development.test
-
id = container.invokeFactory(type_name=“News Item”, id=‘new-news’)
-
obj = container[id]
-
obj.setTitle(‘This is my dumb test’)
-
import transaction
-
transaction.commit()
-
app._p_jar.sync()
Now you can go into your plone site, and you’ll have the new news, if you can’t see them try going to:
http://localhost:8080/development/test/new-news
Remember changing the url according to your own.
Hope this helps someone
