I am trying to set up through the zcml the engine and session for connection to a database with the use of z3c.saconfig. I am using Plone 4.3.2.
I was following along with a book on Plone 4 called Professional Plone Develop book and under [instance] in buildout.cfg it says to place zcml-additional and it sets the engine and session.
Here is what the instance portion of the buildout.cfg looks like:
[instance]
<= instance_base
recipe = plone.recipe.zope2instance
http-address = 8080
zcml-additional =
<configure xmlns="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/db"
>
<include package="z3c.saconfig" file="meta.zcml" />
<db:engine name="testA" url="mysql://uName:uPass#localhost/GPCL_Asset_Tracker"/>
<db:session engine="testA" />
</configure>
Also, I have a package called gpcl.calibration and in the setup.py file I added underneath install_requires 'MySQL-Python' and 'z3c.saconfig', which work and do not cause a problem in the buildout.
Unfortunately I am getting this error:
ZopeSAXParseException: File "/home/pjdowney/Plone/GPCLAssetTrackerD/parts/instance/etc/package-includes/999-additional-overrides.zcml", line 2.0, duplicate attribute
Is zcml-additional defined elsewhere not in buildout.cfg? In the book, I did notice it has underneath [instance] the http-address and user, which seem to have been moved to underneath [buildout] instead.
This is a typo: you cannot have two attributes both named xmlns on your configure element. Going by the <db:engine that follows, it probably should read
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:db="http://namespaces.zope.org/db"
>
Related
I am using Alfresco Community 5.0.d and trying to find the files related to live search.
I would like to remove or modify the people finder in live search. Please let me know the files or way to achieve it.
Share-header.get.js info is below:
if (!user.isAdmin)
{
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_MY_FILES");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_SHARED_FILES");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_SITES_MENU");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_PEOPLE");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_REPOSITORY");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_BECPG");
}
//Disable people search
var headerSearch = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SEARCH");
if (headerSearch)
{
headerSearch.config.showPeopleResults = false;
headerSearch.config.placeholder="Search files, sites";
}
Below is extensions.xml
<extension>
<modules>
<module>
<id>Update Site Header</id>
<version>1.0</version>
true
org.alfresco.share.header
com.site-header
share-header
As I added below lines, now I could see that my file, shared file and other menu items being removed for user(non admin) but no changes in search box.
Credit : Muralidharan
<auto-deploy>true</auto-deploy>
<evaluator type="default.extensibility.evaluator"/>
Screenshot of html structure for search box.
Below is screenshot of modules/deploy:
Screenshot of debug mode :
Thanks in advance
We excluded people search using below script.
//Disable people search
var headerSearch = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SEARCH");
if (headerSearch)
{
headerSearch.config.showPeopleResults = false;
headerSearch.config.placeholder="Search files, sites";
}
And we placed this file, in the following path.
C:\Alfresco5\tomcat\webapps\share\WEB-INF\classes\alfresco\web-extension\site-webscripts\com\quanticate\header\share-header.get.js
Use the module extension to apply your customisation in Share and store this file into alfresco\web-extension\site-data\extensions\extensions.xml
<extension>
<modules>
<module>
<id>Menu customisation</id>
<auto-deploy>true</auto-deploy>
<evaluator type="default.extensibility.evaluator"/>
<!-- default.extensibility.evaluator is applied to determine if the module should be executed -->
<customizations>
<customization>
<targetPackageRoot>org.alfresco</targetPackageRoot>
<sourcePackageRoot>com.quanticate.header</sourcePackageRoot> <!-- Your package path should go here -->
<alwaysApply>
<webscript>share-header</webscript>
</alwaysApply>
</customization>
</customizations>
</module>
</modules>
</extension>
I followed below link and it worked like a charm.
https://community.alfresco.com/message/806438-re-not-able-to-disable-suggestion-in-alfresco?commentID=806438&et=watches.email.thread#comment-806438
Summary:
Override the live-search-people.get.json.ftl file to produce no result for live search.
Steps:
Extract alfresco-remote-api-5.0.d (/Applications/alfresco-5.0.d/tomcat/webapps/alfresco/WEB-INF/lib)
Goto /Applications/alfresco-5.0.d/tomcat/webapps/alfresco/WEB-INF/lib/alfresco-remote-api-5.0.d/alfresco/templates/webscripts/org/alfresco/slingshot/search and copy live-search-people.get.json.ftl
Then goto Applications/alfresco-5.0.d/tomcat/shared/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search (create new directory if not exist) and paste the file copied earlier
Open that file in editor like sublime text and replace with following code.
<#import "../../repository/person/person.lib.ftl" as personLib/>
<#escape x as jsonUtils.encodeJSONString(x)>
{
"totalRecords": 0,
"startIndex": 0,
"items":
[
]
}
Restart the tomcat and test live search.
Thanks to Angel and Alex for answer followed with clarification.
Interesting finding that I was using Aikau 1.0.8 Because of that the changes recommended by Muralidharan was not working (older version) so now as I move to newer version of Aikau (1.0.101) then those changes are good to go.
Thank you Muralidharan!
/****NOTE****/
If your using older version of Aikau (like 1.0.8) than you have to override the extension
Or
If your using newer version of Aikau (like 1.0.101) than you can directly make changes.
You have to override the files containing the webscript response. Search for the Freemarker template files which have the rendered output and over-ride it .
In previous versions of Plone, QuickInstaller took care of automagically removing some stuff on uninstall time; that was the case of browser layers and resource registry resources. Now in Plone 5 is a best practice to include a GenericSetup profile to explicitly uninstall those thins.
I folowed up Keul's blog post on uninstalls and added a browserlayer.xml file to my package uninstall profile as follows:
<?xml version="1.0"?>
<layers>
<layer name="collective.fingerpointing" remove="true" />
</layers>
but my package is not removing it.
any hints?
code is in: https://github.com/collective/collective.fingerpointing/pull/6
test results are in: https://travis-ci.org/collective/collective.fingerpointing/jobs/110195902
I'm just one test away of accomplish compatibility of my add-on!
For unregistering browser layers, the interface is ignored. Only the browser layer name is important. That has to match the name, under which the browser layer was registered before.
The problem was in the test: I was testing against the name of the interface and another package (in my case, plone.app.event) had a browser layer with the same name (IBrowserLayer):
(Pdb) registered_layers()[4]
<InterfaceClass plone.app.event.interfaces.IBrowserLayer>
I was using this:
def test_addon_layer_removed(self):
from plone.browserlayer.utils import registered_layers
layers = [l.getName() for l in registered_layers()]
self.assertNotIn('IBrowserLayer', layers)
I change it to the following:
def test_addon_layer_removed(self):
from collective.fingerpointing.interfaces import IBrowserLayer
from plone.browserlayer.utils import registered_layers
self.assertNotIn(IBrowserLayer, registered_layers())
That's why is important to have the right tests in place.
I'm deprecating a Site Setup add-on configlet. The procedure I'm following is add the remove="true" property to controlpanel.xml
<!-- profiles/default/controlpanel.xml -->
<configlet
title="MyConfiglet" ...
remove="true">
<permission>Manage portal</permission>
</configlet>
and then execute an upgradeStep. I tried with
<!-- upgrades/configure.zcml -->
<genericsetup:upgradeSteps ...>
<genericsetup:upgradeDepends
title="Remove Configlet"
import_steps="plone.app.registry controlpanel"
/>
</genericsetup:upgradeSteps>
But after executing the upgrade step, I still can see the configlet in /##overview-controlpanel.
What am I missing? What do I need to remove the configlet from the control panel?
Thanks.
The process of removing something from Plone involves more or less the same steps you used to add it; in this specific case you have two ways of doing it: programmatically or using Generic Setup.
programmatically
I think this is easier as involves no more than a few lines of code and you can debug in case of problems.
just use the following code on your upgrade step:
def remove_configlet(self):
from plone import api
config_tool = api.portal.get_tool('portal_controlpanel')
configlet_id = 'MyConfigletId'
config_tool.unregisterConfiglet(configlet_id)
using Generic Setup
create a controlpanel.xml file inside the profile you're registering for your upgrade step; this file should contain exactly the same stuff used to add the configlet plus the remove="True" attribute.
you can find a working example of this on the upgrade_10_to_11 profile of Products.TinyMCE:
controlpanel.xml
upgrades.py
<?xml version="1.0"?>
<object name="portal_controlpanel" meta_type="Plone Control Panel Tool"
xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="plone.tinymce">
<configlet title="TinyMCE"
action_id="tinymce" appId="TinyMCE"
category="Products"
condition_expr=""
url_expr="string:${portal_url}/portal_tinymce/##tinymce-controlpanel"
visible="True"
i18n:attributes="title"
remove="True">
<permission>Manage portal</permission>
</configlet>
...
</object>
def upgrade_10_to_11(setuptool):
"""Upgrade TinyMCE from 1.0 to 1.1"""
...
# Unregister old js and register new js
setuptool.runAllImportStepsFromProfile('profile-Products.TinyMCE:upgrade_10_to_11')
in case of doubts take a look at Luca Fabbri's excelent blog post on How to make your Plone add-on products uninstall cleanly.
How does the Tridion GUI Extension config map the names to the JS file? For example, I am using Jaime's HelloWorld post with example files. The most important part feels to be the CommandSet section.
<cfg:commandset id="HelloWorldCM.Interface">
<cfg:command name="HelloWorldCM" implementation="Extensions.HW"/>
<cfg:dependencies>
<cfg:dependency>HelloWorldCM.Commandset</cfg:dependency>
</cfg:dependencies>
</cfg:commandset>
Can someone please help me understand the following attributes and how they map to the underlying .js file for the extension?
name
implementation
cfg:dependency
I have tried changing these things in both config and js file but how they are mapped is a mystery.
The three attributes you mention are really all pointers that tie the whole extension together. If you look higher up in the Jamie's sample, you will see this:
<ext:contextmenus>
<ext:add>
<ext:extension name="HelloWorldCMExtension" assignid="" insertbefore="cm_refresh">
<ext:menudeclaration>
<cmenu:ContextMenuItem id="ext_HelloWorldCM" name="Hello World!" command="HelloWorldCM"/>
</ext:menudeclaration>
<ext:dependencies>
<cfg:dependency>HelloWorldCM.Example</cfg:dependency>
</ext:dependencies>
<ext:apply>
<ext:view name="DashboardView"/>
</ext:apply>
</ext:extension>
</ext:add>
</ext:contextmenus>
This XML adds a button to the CME's context menu.
command="HelloWorldCM" refers to the command with the matching name attribute in the commandset
implementation="Extensions.HW" in the command set actually refers to the namespace in the accompanying HellowWorldCM.js file
cfg:dependency points to the top of the config file at the <cfg:group name="HelloWorldCM.Commandset" merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor" merge="always"> node in order to know which CSS and JS to include.
I'm using paster to create my content types and views. I'm using Plone 3.3.
In my config.py:
ADD_PERMISSIONS = {
# -*- extra stuff goes here -*-
'MyContentType': 'mynamespace.mypackage: Add My Content Type'
}
In my __init__.py:
for atype, constructor in zip(content_types, constructors):
utils.ContentInit('%s: %s' % (config.PROJECTNAME, atype.portal_type),
content_types=(atype, ),
permission=config.ADD_PERMISSIONS[atype.portal_type],
extra_constructors=(constructor,),
).initialize(context)
...and in browser/configure.zcml:
<browser:page
for="*"
name="myview"
class=".myview.MyView"
template="myview.pt"
allowed_interface=".myview.IMyView"
permission="the permissions defined in ADD_PERMISSIONS: what is the name I can put here?"
/>
I know I can create custom permissions using colective.autopermission, but I I already created them using config.py, how can I use them in my configure.zcml?
EDIT: Hum, browser views defined in ZCML use the Zope 3 permission id, but my config.py is using the Zope 2 permission title. I need to use collective.autopermission to create the zope 3 permission id, or can I use another approach (like just creating a permissions.zcml, with title attributes, using the same title provided in ADD_PERMISSIONS dict, because the permissions in zope 2 style are already created so I don't need collective.autopermission)?
You should indeed use collective.autopermission and create a permissions.zcml (and load that in your configure.zcml, or just add the lines in configure.zcml itself) that contains statements like this:
<permission
id="mynamespace.mypackage.AddMyContentType"
title="mynamespace.mypackage: Add My Content Type"
/>
You can pick a different id, but the title needs to be the same as the title you have given in config.py.
EDIT:
Note that Zope2 versions in use in Plone 4.0 or higher have the collective.autopermission patches included so you do not need to use that package anymore; you do still need the permission declaration in zcml of course.
On Plone 3 you do need the collective.autopermission package and you should depend on it in your setup.py and add <include package="collective.autopermission" /> in your zcml before the permissions registration (or use z3c.autoinclude, included in Plone 3.3, to load that zcml automatigically).