How do I implement a dynamic role in Plone 3? - plone

I want to allow access to certain content to certain users for a limited time,
using a 'Dynamic Role' in Plone 3 ( http://collective-docs.readthedocs.org/en/latest/security/dynamic_roles.html ).
To this end I've created an add-on with a copy paste of example code - except that for now getDummyRolesOnContext() always returns my role.
But Plone never calls, or instanciates my DummyLocalRoleAdapter, and obviously my users never get the role assigned.
Here's what I know so far:
My dynamic role is defined in a rolemap.xml and get's created upon add-on installation.
My add-on is being imported - an exception on it's first line prevents Zope from starting
None of DummyLocalRoleAdapter are being called - I've spiked all of them with warnings and exceptions.
The adapter does get registered.
How do I continue debugging this - what's the magic part I'm missing?
Thanks!

My guess is that you need to somehow activate borg.localprole PAS plug-in in acl_users:
https://github.com/plone/borg.localrole/blob/master/borg/localrole/utils.py
There might have been borg.localrole add-on installer entry in the past, but now there doesn't seem to be one. My guess is that you need to call the actions from borg.localrole add-on setup code manually in your own add-on.
acl_users when borg.localroles is correctly installed:

Related

Wordpress - Best practice for pushing updates to multiple servers using version control

So I am about to add another WP blog, but I'd like to keep it under version control. Then I started thinking, how would that affect my current WP workflow. Based on my limited xp in using WP, when an update is pushed from WP dev team, I see an indication in my admin control panel. From here I can simply click the button, and the changes are implemented behind the scene. This approach is great for a single WP instance outside of version control, but what about more nodes, and in version control?
Some of the WP updates include both code and schema changes, so I can't simply publish the code without also implementing the new schema changes. The best I can figure it is to do the following:
Localize current WP version stored in version control
Download latest (stable) wp files
Extract to local path (created in step 1)
Diff changes (optional)
Commit changes to version control
Log into each server
Put into maintenance mode
Pull latest changes
Implement new schema changes (????)
Test
Take out of maintenance mode
Step 9 is what is tripping me up. Do I do a schema dump from my local (freshly updated) schema, then import that schema for every server (or use provided schema change file if WP included id).
Is there a better approach to this?
---- EDIT 1.20.2014 ----
After further consideration, I wonder if setting up some type of mysql replication would be the way to go? Have one node access with read/write access so it can make changes which are restricted to database only (i.e. de-activating a widget), but have other servers serving up the blog content read from readonly mysql instances which are replicated to. This way only one server is making changes from which the others will pull. During my research I have noticed that some changes like alterations to child theme via functions.php or style.css can be tracked in version control, but other changes like activating/de-activating widgets are purely sql based, which would be impossible to track in version control.
Is there a better approach to this?
Don't touch WP core (do you really need it?)
OR
Hack core only once in order to replace default repository's URL of WP-core with your's and later use system auto-updater with your repository

AccessDenied in Orchard CMS 1.4.1

I converted one of my solution to Orchard 1.4.1 with proper database.
Q1: Whenever I run or goto any link by clicking menu item then it always hits to AccountController/AccessDenied method of Orchard.Users. why?
Q2: How to resolve this?
Please help
There are two scenarios in which this may happen:
You updated from 1.3 (or older) versions to 1.4.1. If that's the case - check the 1.4 upgrade information. EDIT: Actually this is probably not your case - you would get 404's, not AccessDenied, in this scenario.
You are using the source code from recent 1.x development branch. There is a new module in the works that will allow to restrict visibility of certain pages to specific users. If that's the case - go to admin screen and assign Page "View" permissions to Anonymous role.

how do I update a plone custom policy (e.g. mysite.policy) add-on

When I first created my Plone (4.1) site, I made a mysite.policy add-on to include some custom users and a custom workflow.
I need to make some corrections to both the workflow and the permissions. I updated the src to include these changes, but updating the package in through the Plone add-on manager (uninstall - install) does not work. As soon as I uninstall the status of all my entries switches to "local policy", so I cannot get the fine-grained status setttings back when I reinstall.
Also, the user permissions do not seem to change. Possibly because they were already created at set-up of the site. But I cannot figure out how to code a change to permissions versus a setup of permissions in the rolemap.xml. I assumed that whatever is in that xml is what rules my plone world, but that does not seem to be working.
So far I cannot find anything about this in the manuals and books I have at hand. Any hints how to solve this? Perhaps the only way to go about this is a series of manual changes through ZMI, but it is so much less elegant to do it that wat.
There's plenty of options. I'll try to describe a couple of them.
If your changes include only changes in Generic Setup profile of your site policy (./src/my/site/policy/profile/default/-files) and you don't want to automate the upgrade, you could simply update the profile-files and re-run those specific import steps for your policy:
Open ZMI (site/manage) for your site and look for portal_setup.
Select Import-tab when on portal_setup.
Select the profile of your site policy from Select Profile or Snapshot-list (the title of your profile is defined by the registerProfile-directive in configure.zcml or profiles.zcml of your policy product).
Click to select import steps for Role / Permission Map and Workflow Tool.
From the bottom of the page, deselect Include dependencies.
Click Import selected steps-button.
Go to portal_workflow-tool on ZMI and Update security settings, if your workflow update should modify permission in existing workflow states.
These steps should re-import only the selected import steps of you site policy product's Generic Setup -profile. Re-importing individual steps this way should be quite safe, but be careful: accidental clicks at portal_setup screens may have unpredictable consequences.
These steps can also be automated by defining something called Generic Setup Upgrade Step.
I hope that the default Generic Setup -profile of your site policy product includes metadata.xml with line <version>1</version>.
Update that line to <version>2</version>.
Open the zcml-file with registerProfile-directive and, after it, add
<genericsetup:upgradeDepends
source="1" destination="2" sortkey="1"
title="Upgrade my.site.policy (1 to 2)"
description="Upgrades my.site.policy's default profile from version version 1 to 2."
profile="my.site.policy:default"
import_steps="rolemap workflow"
run_deps="false"
/>
These steps should register such an upgrade step from the profile version 1 to 2, which re-imports steps rolemap and workflow (rolemap.xml and workflows.xml). You should be able to run the upgrade step from the Plone Site Setup's Add-ons-screen, where there should now be an upgrade button after your installed policy product.
As mentioned by #toutpt, the Collective Developer Manual has more examples on upgrade steps. If you have ever wondered, why it's recommended to use integers in metadata.xml, usually independently from the product's release version number', this is the reason :).
Any changes that need upgrade must be shown by increment the number in profile/default/metadata.xml (keep integer). Next you have to write an upgrade step. It will add an upgrade button in the addons control panel.
Please follow this tutorial to learn how to create an upgrade step: http://collective-docs.readthedocs.org/en/latest/components/genericsetup.html?highlight=upgradestep#upgrade-steps

Drupal 7 custom module does not enable

I am trying to create a custom module (as a content/node type) but it's malfunctioning.
Upon creating the desired .module and .info files, I go into Adminstrator/modules and enable the module. Upon enabling this module, all I see is the adminstrator view expand itself
Compare this with the regular administrator page that renders itself while carrying out administrative tasks:
It is expected to appear in the new Content types button but it does not, and when I look back into the Modules menu, the node is not enabled, even though I enabled it and saved configuration.
There are no error reports either and I am using the official Drupal documentation to create a module as a node_example...the code for the same can be obtained at this link:
http://drupalcontrib.org/api/drupal/contributions--examples--node_example--node_example.module/7
Anybody with any inputs on what's going wrong here? Most importantly this seems to be an error present in the official documentations for creating a module as a node type!

Creating DNN Portal through Code (or programming)?

I have one portal with 3 modules inside it, now my requirement is i would like to create
new portal for every client registered in my DNN site.
So, i have one interface for registration, so as soon as client registers entirely new parent portal should be created with all the modules.
How can i achieve this functionality ???
I would suggest digging into the admin files that come as part of the default DNN installation and look for the code that creates a new portal from there. It will ultimately be calling a stored procedure to create the necessary data in the SQL tables. You might get away with just calling the stored procs but the admin code probably calls several different ones to setup the default security settings.
Curiously what alias will each of these portals use? It's not clear why you need a complete portal for each user. The DNN segmentation already allows you to show different content based on role membership. Why the need for a whole portal per user?
Use the site wizard to create template of the current portal and during client registration programmatically execute the template. You may also want to automate the site setup in IIS.
Well, You can easily do it! Login to host and go to portals. Click on create new protal.
See which control is responsible for creating new portal. you can simaply get it by using firebug and look into client id of link or text box.
Once you do that, you will find the code you can use.
tell me if you need more help with it, I'm good with what you want to do!

Resources