Avinash
Avinash

Reputation: 33

Plone:Calling external python script from plone page

I have some entries(say products in a database table) and i need to collect details of them on page load from the database.

I have a global python script(getValues) to fetch data.

How to call the script since the product are categorized and are present in different folders and the script resides in main folder "Products".

  1. Books
    • Book1
    • Book2
  2. Mobile
    • Mobile1
    • Mobile2
  3. getValues

Book1,Book2,Mobile1,Mobile2 are my pages which has been created using plone interface (add New-->Page; not via ZMI)

what I tried is as follows:

<div tal:repeat="records context/getValues">
<span tal:replace="records/Name"></span>
<span tal:replace="records/Price"></span>
</div>

and my python script(getValues)

records = {'Name': 'Test','Price': 20,}
return records

Any help or pointers would be great so that I can move ahead.

As per the suggestion received by you guys, here is my detailed question

screenshot of the script added in portal_skins/custom

Why the script is not getting called on page load event ?
I need the python script to be called on page load event as Form Setup Script in PloneFormgen

Upvotes: 1

Views: 803

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83676

If you put your Python script in any folder under plone_skins it is available for every content item.

E.g. put your script called foobar to custom under plone_skins

Then you can call it:

  <div tal:repeat="records context/foobar"> 

Upvotes: 2

Related Questions