I add a new choice field named course to Dexterity Content Type File in a new created instance. In order to use the field "course" as criteria in /++add++Collection, I follow this guide and add these to the file registry.xml in plone/buildout-cache/eggs/plone.app.querystring-1.3.14-py2.7.egg/plone/app/querystring/profiles/default/registry.xml:
<records interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.course">
<value key="title">course</value>
<value key="description">A custom course index</value>
<value key="enabled">True</value>
<value key="sortable">False</value>
<value key="operations">
<element>plone.app.querystring.operation.string.is</element>
</value>
<value key="group">Metadata</value>
</records>
But I can not find "course" in criteria list.
What can I do to get this criteria for collection?
First of all: modify the Plone source code is a bad practice. Don't do it. Never.
The guide you are referring to is OK, but it's intended to be used in a new Plone add-on you must develop and add to your installation.
Please read the "Develop Plone Add ons" guide.
In your case: you need a really simple add-on with a simple generic setup step that contains a registry.xml file with your code above.
After installing the add-on (and every time you will reinstall it) your registration will be added to your site.
Related
I need to enabled files with same name in same folder in Alfresco.
I try to create custom association, but I can't see the files in Share (bellow you can see my custom type code).
I can solve this changing the properties duplicate for true on contentModel.xml, but this type of global change is not recommended.
Any idea when I can enable duplicate files in Alfresco? Is correct create another type and define custom association for this OR do I really have to change the global file in contentModel.xml?
<type name="acme:project">
<title>Project folder</title>
<parent>cm:folder</parent>
<associations>
<child-association name="acme:contains">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>acme:document</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
<duplicate>true</duplicate>
<propagateTimestamps>false</propagateTimestamps>
</child-association>
</associations>
</type>
*PS: Sorry for my English.
You can't configure this. Uniqueness on the filename in a directory is also enforced by a unique constraint directly in the database. You would break a lot of funktionallity if you change that. Alfresco implements the fileserver concepts and a fileserver only supports one file with the same path. Use your custom property instead.
I don't have your use case, so my proposition may be unsatisfying, but :
if you want to see your document in Share, it might be possible to custom your share interface to show another property than the document name, a property on which you can have the same value for nodes in the same folder.
Another proposition would be to categorise your documents and use the classification plan you made (with hierarchical categories instead of folder organisation) to access to your documents.
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.
In the current Plone 5 coredev buildout, I am trying to write a GenericSetup uninstall profile for an add-on that registers some css in cssregistry.xml. In Plone 5, portal_css and portal_javascripts are empty, with all those resources now automatically loaded in the Resource Registry instead. But there is no corresponding uninstall. If I have a single css resource, I get the following records in the Resource Registry:
<record name="plone.resources/resource-myaddon-stylesheets.conf">...</record>
<record name="plone.resources/resource-myaddon-stylesheets.css">...</record>
<record name="plone.resources/resource-myaddon-stylesheets.deps">...</record>
<record name="plone.resources/resource-myaddon-stylesheets.export">...</record>
<record name="plone.resources/resource-myaddon-stylesheets.init">...</record>
<record name="plone.resources/resource-myaddon-stylesheets.js">...</record>
<record name="plone.resources/resource-myaddon-stylesheets.url">...</record>
(I get all these even though I have no js resources, and they all have an empty value, except for the css record.)
In addition, there is a new <element> in the following record:
<record name="plone.bundles/plone-legacy.resources" interface="Products.CMFPlone.interfaces.resources.IBundleRegistry" field="resources">
...
<value>
...
<element>resource-myaddon-stylesheets</element>
</value>
</record>
As I create my GS uninstall profile, it's simple enough to remove the former 7 records in registry.xml. But how do I remove the single <element> from the latter record? I looked through the test in plone.app.registry, but removing an element does not seem to be covered.
Ultimately, it would be great if the uninstallation could be handled automatically, just like the installation is.
Seems like the workaround is to add something like this to Extensions/Install.py:
def _removeBundleFromRegistry():
logger.info('Removing bundle reference from registry')
record = 'plone.bundles/plone-legacy.resources'
resources = api.portal.get_registry_record(record)
if u'resource-myaddon-stylesheets' in resources:
resources.remove(u'resource-myaddon-stylesheets')
def uninstall(portal, reinstall=False):
if not reinstall:
...
_removeBundleFromRegistry()
...
Too bad.
You have to use something like this:
<record name="plone.bundles/plone-legacy.resources" interface="Products.CMFPlone.interfaces.resources.IBundleRegistry" field="resources">
<value purge="false">
<element remove="true">resource-myaddon-stylesheets</element>
</value>
</record>
You can see a working example in the uninstall profile of the brasil.gov.paginadestaque package.
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.
I want to create a catalog metadata with a computed string. So following Aspeli's book and the developer manual I proceeded to create an indexer:
# indexer.py
#grok.adapter(Entry, name='bind_representation')
#indexer(Entry)
def bindIndexer(context):
print str(IBindRepresentable(context))
return str(IBindRepresentable(context))
and register the index with genericSetup:
<!-- profiles/default/catalog.xml -->
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
<index name="bind_representation" meta_type="ZCTextIndex">
<!-- I tried with meta_type="FieldIndex" too -->
<indexed_attr value="bind_representation"/>
<!-- copied from other text metadata -->
<extra name="index_type" value="Okapi BM25 Rank"/>
<extra name="lexicon_id" value="plaintext_lexicon"/>
</index>
</object>
The problems are: (1) only the index is registered, not the metadata, and (2) After reindex all the zodb, bind_representation still doesn't find any entry to index, even when they are.
The examples cited only deal with pre-existent indexes, so I'm not sure about the content of catalog.xml. bindIndexer seems not to be called at all, since its print statement is never executed. I copied bindIndexer to entry.py too, to get sure it wasn't being ignored, but still nothing.
What am I missing?
Thanks.
1- In order to add a new metadata, you have to use this syntax:
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
...
<column value="bind_representation"/>
</object>
2a- you are adapting your content class, you should adapt your content interface (IEntry most likely).
2b- you are using a ZCTextIndex: that index won't show you all entries anyway (even following the previous point) because it's based on a lexicon. You should probably use this instead (unless you have specific bounds):
<index name="bind_representation" meta_type="FieldIndex">
<indexed_attr value="bind_representation"/>
</index>
More info:
http://bluebream.zope.org/doc/1.0/manual/componentarchitecture.html#adapters
http://maurits.vanrees.org/weblog/archive/2009/12/catalog