How can I programmatically change the state of all objects in a folder to 'published'?
All are default objects of Plone 4 as Link, Page, Document, and so.
Cycle all objects in that folder and publish them:
wftool = getToolByName(folder, 'portal_workflow')
for child in folder.objectValues():
wftool.doActionFor(child, 'publish')
Related
New to Ignition, I would like to understand how to dynamically create windows pages containing templates binded to UDTs.
I created a Template named TGBT having 4 parameters:
-DeviceName (string)
-TagBlock (string)
-TagOffset (string)
-TgbtNr (TGBT, drop target)
I created a UDT named TGBT with the same Data Type Parameters
and added in the data type structure new OPC using OPC Item Path [{DeviceName}]{TagBlock},I{TagOffset}
Then I created instance of UDT with add hoc values:
This works fine when I create the page using the Ignition Designer
I created a script that read a CSV file (will be database at the end) and creates UDT instances accordingly:
It works fine, I can see OPC values updated in the tag browser, with the expected OPC Item Path.
I understood Template canvas are the proposed way and populated the Templates dataset.
The script populates the template with provided parameters eg:
{"DeviceName":Elec,"TagBlock":DB200,"TagOffset":48}
The Templates instances are correctly placed in the Template canvas, but I should be wrong in parameters as the Template fields, labels (...) are not updated accordingly.
Have someone tried this, could help me?
Xavier
Also check out this forum thread to generate templates on a container without canvas: https://forum.inductiveautomation.com/t/dynamically-add-component-to-root-container/12735/11
I'm using collective.transmogrifier.sections.folders pipeline section to create parent folders of content I'm importing into Plone.
My problem is those folders are created without a title and are not being published.
How can I solve that?
Try adding this sections to your pipeline (you may already have the second one):
# Publish all folders
[publish_all_folders]
blueprint = collective.transmogrifier.sections.inserter
key = string:_transitions
value = string:publish
condition = python:item.get('_type') == "Folder"
# Actually run the given transition to update the workflow state
[workflowupdater]
blueprint = plone.app.transmogrifier.workflowupdater
I have a Plone project which I need to fork; sadly, the UID of the temp folder (for Archetypes objects) is used in the code (as a module level variable, at least, not as strings all over the source tree).
When starting with a fresh ZODB - can I create the temp folder and set the UID? Or should I simply change that constant in the new development branch?
You can set the uid for an AT object by...
obj._setUID(uid)
The _setUID method is defined in Products.Archetypes.Referencable Module
For more information you can also check the plone.app.transmogrifier uidupdater section.
I have notices that types created with paster on the file system can be changed using the TTW editor.
When I reinstall the product the TTW changes persist, and the model file seems to be ignored. How can I discard these changes? Is there a guide to the relationship between web changes and file system changes?
A content type's entry in the portal_types tool has 3 properties related to where the model is loaded from. They are checked in this order:
model_source: The XML model, inline
model_file: Path to a file which contains the XML model
schema: Dotted path to a Python schema
My guess is that you need to make your filesystem product's installation profile explicitly empty model_source, so that it won't take precedence over model_file and schema.
I have many mp3 files stored on my server already from a static website, and we're now moving to drupal. I'm going to create a node for each audio file, but I don't want to have to upload each file again. I'd rather copy the files into the drupal files directory where I want them, and then associate the nodes with the appropriate file.
Any ideas on how to accomplish that?
Thanks!
I am not sure if I am going to propose a different approach or if I am about to tell with different words what you already meant with your original question, but as you want the nodes to be the files, I would rather generate the nodes starting from the files, rather than associating existing nodes with existing files.
In generic terms I would do it programmatically: for each existing files in your import directory I would build the $node object and then invoke node_save($node) to store it in Drupal.
Of course in building the $node object you will need to invoke the API function of the module you are using to manage the files. Here's some sample code I wrote to do a similar task. In this scenario I was attaching a product sheet to a product (a node with additional fields), so...
field_sheet was the CCK field for the product sheet in the product node
product was the node type
$sheet_file was the complete reference (path + filename) to the product sheet file.
So the example:
// Load the CCK field
$field = content_fields('field_sheet', 'product');
// Load the appropriate validators
$validators = array_merge(filefield_widget_upload_validators($field));
// Where do we store the files?
$files_path = filefield_widget_file_path($field);
// Create the file object
$file = field_file_save_file($sheet_file, $validators, $files_path);
// Apply the file to the field, this sets the first file only, could be looped
// if there were more files
$node->field_scheda = array(0 => $file);
// The file has been copied in the appropriate directory, so it can be
// removed from the import directory
unlink($sheet_file);
BTW: if you use a library to read MP3 metadata, you could set $node->title and other attributes in a sensible way.
Hope this helps!
The file_import module doesn't do exactly what you want (it creates node attachments instead of nodes), but it would be relatively simple to use that module as guidance along with the Drapal API to do what you want.