Insufficient Privileges When Accessing an Object

Hello. I'm just new in plone.. I created a script that can be accessed through a url (domain.com/testMigrate) but its giving me an "Insufficient Privilege Error" whenever I try to access it in the browser. Here's the full code, it just get the objects of a specific portal_type:
https://pastebin.com/DVBJ12JE

https://docs.plone.org/develop/plone/security/permissions.html#debugging-permission-errors-verbose-security

1 Like

If your script is not part of an add-on that is on the server file system then it is probably running in Restricted Python, which will not let you do as much as (unrestricted) Python. But as Andreas says, you need to look in the Site Setup "Errors" control panel to see the details of what is giving you the error.

1 Like

Oh, and welcome! :slight_smile: What are you using Plone for initially?

1 Like

Yeah. I guess its running in restricted python. I just created the python script through the manager page in the <domain.com>/manage . Then I access the script through the url. Is it possible to use unrestricted python in the /manage and not by creating and running .py files manually in the server?

Hi Sir.. Python is not really my thing. lol . We have a client who wants to migrate all the data from zope db to MySQL . So I'm testing if I can get all the objects through a script and manipulate the objects and its attributes to create appropriate SQL statements for the MySQL database tables.

Try to create a custom BrowserView, ie using https://docs.plone.org/develop/plone/views/browserviews.html#creating-and-registering-a-view as it won't run in RestrictedPython mode.

Or run a Python script directly on the Data.fs using the method I outlined in https://www.fourdigits.nl/blog/converting-plone-data-to-django/ .

Either way, it is going to take some time get this done, please be aware of that.

2 Likes

probably a faster way might be to use jsonify or collective.importexport or some other method to create a dump of your data in json or csv. Then write an external script to manipulate that. Or use plone.restapi and create a script that interacts with that.
You probably can do it using restrictedpython but there is no a lot of point unless you data us huge and you want to prerpocess it and filter it before it leaves plone. Note collective.importexport does let you do that to some extent and so would the restapi approach I believe.

2 Likes

Thanks Sir. Will check this out. I think I'll try to create a view.

Yeah, the data is so huge. Its around 50k+ objects. The export to xml format is always giving me a gateway timeout error because the data is so big. So I need to find a way to preprocess it :slight_smile:

Hi sir. Sorry for this novice questions. The tutorial to create and register a view requires to edit the configure.zcml . Where is this located? I cant find it in the /manage page.

Hi,
direct access to the possible outputs (raw, output, raw_encoded,...) wont work (since dexterity), i think...
An Browser View is the better (more complex, but more powerful) way to do that

Possible Addons

Follow these instructions

first, you need an external Product/Addon, then you can add your own Browser View

Creating an Addon
https://training.plone.org/5/mastering_plone/eggs1.html

Browser View
https://training.plone.org/5/mastering_plone/views_1.html
and https://docs.plone.org/develop/plone/views/browserviews.html#creating-and-registering-a-view

A good Start

2 Likes

No need to apologize for asking questions :slight_smile: But yeah, the recommended methods require that you use some add-ons or that you write your own. The recommended methods do not involve /manage (the management interface) and cannot be used with the management interface.