Update SearchableText index on dexterity type - plone

I am trying to update SearchableText on my dexterity type ("Resource"), to include file contents from child items, by adding this to resource.py:
#indexer(IResource)
def subFiles(obj):
searchable_text = obj.SearchableText()
for item in obj.getFolderContents({'portal_type': 'File'}, full_object=True):
searchable_text += item.SearchableText()
return searchable_text
grok.global_adapter(subFiles, name="SearchableText")
I know I need an event to update this, but believe I should be able to see the index modified by manually "clearing and rebuilding" from the ZMI, however no changes take place on the value of SearchableText for objects of this content type. I am not seeing any errors either, so I am not sure where the problem lies.

Well, I did not recognise here, that you are using dexterity.
You need the dexteritytextindexer behavior:
https://github.com/collective/collective.dexteritytextindexer
Enable this on your container type.
<property name="behaviors">
<element value="collective.dexteritytextindexer.behavior.IDexterityTextIndexer" />
</property>
With the dexteritytextindexer you have a different approach to index the data on your container. Check the dexteritytextindexer.IDynamicTextIndexExtender.

Related

Set Directory in WiX

I am trying to create a folder at a location different from the application installation location which happens to be C:\Program Files(x86). I am using the following fragment
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Directory Id="PhotosDir" Name="Photos" />
</DirectoryRef>
<!--<SetDirectory Id="PhotosDir" Value="[TARGETDIR]Photos" Sequence="execute"></SetDirectory>-->
</Fragment>
I tried with a SetDirectory element as shown above and also with a CustomAction as shown below. (If I use both, I get an error saying Id is duplicated. Hence I commented it.)
<CustomAction Id="SetPhotosDir" Directory="PhotosDir" Value="[TARGETDIR]Photos"></CustomAction>
<InstallExecuteSequence>
<Custom Action="SetPhotosDir" Before="CreateFolders"/>
</InstallExecuteSequence>
I have a component also defined for this directory element as below.
<Component Id="cmpPhotosDir" Guid="{8F757344-CA0A-42BC-B292-A51CE86B19E2}" KeyPath="yes" Directory="PhotosDir"><CreateFolder/></Component>
But the directory called Photos is always getting created in D drive, even though it is nested inside of TARGETDIR. I actually want to control the location where this directory gets created, probably through UI. I googled for SetDirectory element example, but couldn't find a proper working sample. All I get to see is that I have to use a custom action type 35 or 51. But it is not clear what code should go inside of these custom actions. Also, I am not sure, if these custom actions are required in addition to the SetDirectory element or not. Can anyone please help me achieve this, with some working sample?
The problem is your directory identifier is not PUBLIC. Change its name to include no lower-case letters; use only upper-case letters, numbers, and underscores. (This came up in reverse pretty recently over here.)
I would also probably schedule the action to After="CostFinalize" , or just set the property of the same name Before="CostInitialize. Neither of those are likely to be relevant to your symptoms, however.

Remove custom type in Alfresco

In Alfresco, if a type name is removed/changed all nodes of that type will disappears but still exists.
Using alfresco 5.0.c I've added some custom types:
eg:
<type name="my:test">
<title>Test folder</title>
<parent>cm:folder</parent>
</type>
now i deploy it and create a folder of this type (a simple folder, then change type)
Now i edit the type like this:
<type name="my:test2"> <!-- from my:test to my:test2 -->
<title>Test folder</title>
<parent>cm:folder</parent>
</type>
Deploying this: any "my:test" folder will disappear, but, if I try to create another folder with the same name I get an error becouse the node still exists.
These nodes will not be not even listed within the folder child:
print(document.getChildren());
How can I recover (if possible using the the javascript console) all the "broken" nodes and be able to change the type?
A little preface: as widely stated by Alfresco, if you want to change your custom content model you should change it only incrementally.
This means that you can't remove any properties, types or aspect at definition level of the model, you only can add new definitions in the content model of Alfresco.
So it is a very bad practice to change types "on the fly".
A good practice is to always start with a model as small as you can and then add features as long as you need them.
In your case you should have deleted all nodes referencing my:test type BEFORE changing the model and then safely remove it and finally you should have performed a full reindex. This could be the reason why the repository tells you that the folder exists even if you cannot see it anymore.
As far as I know it is not possible to delete this inconsistent nodes through the console, so my advice is to perform a full reindex. If the issues come up again then you should consider to start again from scratch.
Another approach next time is to add the new type and programmatically hide the older one.

how to set publish dcp for child or other publications to different location without overiding all other settings

I am trying to configure cd_storage and getting issue in setting up dynamic component presentation as they get over written by child and published to same folder from every publication.
I know we can define the publication level settings but once we define that then it expect us to define everything inside that publication tag. We do not want to define every thing 50 times in publication tag.
Could any one suggest the best practice for same.
this is for sdl tridion 2011 sp1
Thanks in advance...
Your problem is in how you defined your storage configuration for the storage which you use to store ComponentPresentations. There is a flag in the definition of a storage which sets exactly this type of behavior: defaultFilesystem. You probably have it set to false which causes all ComponentPresentations from all publications to be stored in the same location. By setting this flag to true you will get ComponentPresentations from different publications stored in different locations. I will give an example to show how this works in cd_storage_conf.xml:
<Storage Type="filesystem" Class="com.tridion.storage.filesystem.FSDAOFactory" Id="defaultCPs" defaultFilesystem="true">
<Root Path="c:\temp\cpRoot" />
</Storage>
....
<ItemTypes defaultStorageId="defaultFile" cached="true">
<Item typeMapping="ComponentPresentation" itemExtension=".jsp" storageId="defaultCPs"/>
....
This is really easy to maintain and will make the Broker to store ComponentPresentations to locations like: c:\temp\cpRoot\pub109\dcp\jsp\*** (here I have publicationId=109).
Hope this helps.

Configuration xml for Content Porter Sdl Tridion 2011

I am trying to invoke content porter from command line. As an input parameter we need to provide a config xml to content porter. I am able to understand most of the pattern of config xml but i am not able to understand the pattern of values for ItemSubType and IsExported tags in import config xml. Can someone help me out in understanding the pattern of values for the above tags.
Thanks in adavnce.
Why do you need to play with this manually? I'm not 100% sure, but I can point you in the right direction.
ItemSubType might be set for components (Xml or Multimedia), Schemas (schema type), or TemplateBuilding block (C#, Assembly, Compound, etc). I think it's mostly used to show if there's a binary content along with the item itself.
IsExported is what it says it is. As you know Content Porter is exporting each item together with the items it depend on. You can filter out some of the dependencies, if you know that you have these items on the target system. For filtered out items, IsExported is set to false. For example, you want to export a component. By default, you will have to export schema of this component, folder in which the schema reside, publication with its default items and whatever other dependenices there might be. But you are 100% sure that on your destination system you already have this publication with the folder you need and schema, so to save time you can decide to filter all of this out and export only component. In this case, schema, and everything else will still be added to dependency table, but IsExported will be set to false.

Saving Configuration Section Error - Elements are merged as attributes

I have created a configuration section designer project to represent nodes of a custom section necessary to read and save from my web application. I am able to successfully create instances of the configuration elements and collections, however when I save the configuration using the referenced System.Configuration.Configuration object and issuing save, the elements get merged into their parents as attributes. An example of the issue is outlined below:
After calling the referenced Configuration.save, the output is as follows:
<savedReports xmlns="SavedReportSchema.xsd">
<resultsSets dataViewId="1" id="4203bb88-b0c4-4d57-8708-18e48f0a1d2d">
<selects keyId="1" sortOrder="1" />
</resultsSets>
</savedReports>
As defined in my configuration section designer project (confirmed by the resulting xsd as well) the output should match the following:
<savedReports xmlns="SavedReportSchema.xsd">
<resultsSets>
<savedReport id="1">
<selects>
<select keyId="1" sortOrder="1"/>
</selects>
</savedReport>
</resultsSets>
</savedReports>
Any ideas? The element collection types are set to BasicMapAlternate however when I set them to AddRemoveClearMapAlternate they are not merged but they are prefixed by "add" rather than "select" or "savedReport" causing the validation to be off.
Turns out AddRemoveClearMapAlternate was the option I needed to correct my problem referenced in the question.

Resources