Plone setuphandler- In a setuphandler, how can I programatically add/create a folderish content type at root of Plonesite? - plone

I have have made a folderish content type called supplier_folder, which displays a list of suppliers that can be added under it, and their information. I can add it through the navigation bar, but I would like to add it programatically during setup.
I have been following the tutorial on custom installer code (http://docs.plone.org/develop/addons/components/genericsetup.html#custom-installer-code-setuphandlers-py) and have looked at creating objects programatically (http://docs.plone.org/develop/plone/content/creating.html).
Unfortunately, the second article says I need to have a folder created. How can I get around this and add the supplier_folder object at the Plone Site outside of a folder?

IIRC, only users with role Manager or Site Administrator can add content to the root of the site; you can overcome this limitation in two ways:
by using the _constructInstance method as it bypasses the permissions when creating an item
by switching roles inside your code with plone.api.env.adopt_roles
I personally prefer the second one.
you can see an example of a pretty complex setuphandlers.py in interlegis.portalmodelo.policy package.

When you create a new Plone site, it's also creating some default content types.
Look at how Plone do: https://github.com/plone/Products.CMFPlone/blob/1471828ee97a8dd84396bad4a3286be514819869/Products/CMFPlone/setuphandlers.py#L119

There are a couple of ways to achieve this. The buildin mechanism is to use GenericSetup in combination with "structure" folder as described here: http://koansys.com/tech/create-plone-initial-content-with-generic-setup
In short you need the following:
Create a folder "structure" in your Generic Setup profile (in general, under profiles/default)
Create a .objects file with the following content: "suppliers,supplier_folder"
in "structure" create a folder "suppliers" with a .properties file and content:
[DEFAULT]
title = Suppliers
description = Some usefull description text
As far as I remember this is ok for simple structures likes your. If you have complex structures with folders and sub-folders and want more specific control you probably need to write python code. I made some stuff here: https://github.com/collective/zettwerk.setup/blob/master/zettwerk/setup/structure.py
But zettwerk.setup is not yet released, but you should be able to integrate the structure.py right into your project. Than you can the handle_structure method into your setuphandlers.py and passing a structure dict like this:
handle_structure(portal, [{'id': 'suppliers', 'portal_type': 'supplier_folder'}])
The advantage of this method is, that you can also control metadata like workflow state, default page setting, portlets, local roles and some others.

Related

How to customize dexterity-through-the-web-content view?

I created a content in my Plone 4.3 site (no grok here) with the very nice Dexterity through-the-web editor. Now I'd like to customize the default view for this content.
I've read Martn Aspelli's book but the problem is that through-the-web content does'nt have a specific interface (so I can't use it to create my specific view).
If you want to do this all through-the-web, then do the following:
Create a template for your view in the "custom" folder of
portal_skins (through the ZMI). You'll probably want to start with a
copy of something like the page template
(portal_skins/plone_content/document_view). Give it a name like
your_content_type_view. Test it by appending /your_content_type_view
to the URL for a sample object.
Edit the Factory Type Information (portal_types/your_content_type/Default
view method) to be your_content_type_view.
What you will have done is create a skin-level view for the type. This is different from the browser views that Martin is discussing, which do indeed require a class. The Dexterity development team is working on a way to provide TTW maintenance of browser views, but that's for a later version of Plone.
Meanwhile, if you later transfer your Dexterity content type to a Python add on, you'll be able to use your template, possibly unmodified for a browser view.

Browse for Project Folders in Build Template TFS 2010

I'm adding a new argument to my custom Build template. The argument is almost identical to the default Projects to Build argument under Required -> Items to Build. It simply shows a dialog window with a list of folders under current TFS Project. I can't figure out what the type of control is. I tried FolderBrowserDialog but it browses the computer rather than the TFS project itself. Any help would be appreciated.
You can set the Editor for this argument to:
Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor, Microsoft.TeamFoundation.Build.Controls
Or
Microsoft.TeamFoundation.Build.Controls.ServerFolderBrowserEditor, Microsoft.TeamFoundation.Build.Controls
See my blog for a detailed set of steps.
All of these types are Internal, so you can't reference them from your own code or see them easily. What you can do, is set them as Editor for a parameter you created in the Build Workflow. You need to specify Typename, Assemblyname. You can find these items in the MetaData section of your Build Template.
Add your argument to the workflow:
Open the Metadata property:
Set the editor for your property:
A multi-folder select dialog is not part of the Default UI Editors. You'd have to roll your own. Either use Reflector to see how the existing ones work, or use Reflection to invoke th existing editors as part of your new editor.
It's not going to be pretty code either way, but it would work.

How would one set the default view of content that is imported via Generic Setup (structure)

I already know how to programatically set the default view content, in my specific case, a Folder, or how to use the Plone UI to do it. In my case, I am creating a large skeleton of content via GenericSetup and I need a set of folders to have a specific content item in each folder be the default view.
So, I have a folder structure like so:
folder1/
-- .properties
-- page1
-- homepage1
folder2/
-- .properties
-- page2
-- homepage2
I would think that in:
profile/default/structure/folder1/.properties
you would be able to add:
DefaultView = homepage1
or similar. So the question is: "Is it possible to set the default view of a content item using Generic Setup?"
This answer might also work; I haven't tried it yet because I'd like some feedback on my question before moving away from GS to using ZCML.
How to define default views in Plone
The GS structure importer doesn't support this; it has no idea about the (Plone specific) Dynamic Layout support.
You'll have to write your own custom GS step to do this, I am afraid, or perhaps use something like plone.app.transmogrifier (it includes support for browser defaults and collective.transmogrifier includes a GS step) to configure this.

Easiest way to create a Module in DotNetNuke 6 and to debug

Can I avoid all the packaging and just create a Web application with a .ascx file and use that? The closest thing I can find is this article which is for 5.1 and does not completely work for v6.
http://mestanzasoft.wordpress.com/2011/03/27/creating-a-dotnetnuke-dnn-module-with-an-ascx-control/
So if there is a more up to date tutorial for v6 let me know please.
You should be able to choose Create New Module from the Host -> Extensions page, and then choose the control (which, I think, is what the blog post said). What specifically isn't working?
One thing that may be an issue you're running into is that the control needs to inherit from IModuleBase (probably via PortalModuleBase). You can't just drop a control that knows nothing about DNN in the website and get DNN to make it into a module (though you can make a thin wrapper around a control like that).
Yes you can.
If you go to Host > Module Definitions and click on Create New..., you will find there are there ways to create a new module:
New : That will allow you to create a simple module with single view control. You have to provide module information and create parent folder to do this.
Control: This will allow you to create new module from a control. If you don't want to create a new module folder and control at UI, you can just add a new folder to desktopmodules folder and drop an ascx control which inherits from DotNetNuke.Entities.PortalModuleBase and then use this option to provide correct folder and control that you have created and you are done.
Last option is to create it using manifest and generally useful when you want to split single module with multiple definition to different modules.
Please let me know if you have more questions.
Thanks
In DNN 6.0 you have to go to Host - Extensions...
then hover over the semi-transparent "Manage" button, which you can barely see (hidden behind the word EXTENSIONS, perhaps), and wait for the popup dialog, and THEN click "Create New Module".
:(

Drupal6: View that shows a directory structure

I've built a content type to handle document upload. My content type uses a Book node to handle directories/subdirectories and I would like to show a couple of Views that shows the directories structure. When clicking on a directory I would like to show, in another view, all the documents inserted in that directory.
Do you know any existing examples of Views/Panels? That shows a similar structure, as in the Windows Explorer, using Views2?
You can use this module: views_tree
Also tree-like can be built via argument handlers...

Resources