Avoid creation of Plone's default content - plone

I'm working in a project that creates a Plone 4.3 site that installs plone.app.contenttypes as it's default content types. After site creation I see all default content (the front page and some folders and collections) that are still Archetypes-based content.
I want to avoid the creation of that content and I want to know if there's a better way of getting rid of it that manually erasing it in a post install step.
I need an empty site by default.

You need to setup the Plone Site the following way:
from Products.CMFPlone.factory import addPloneSite
from Products.CMFPlone.factory import _DEFAULT_PROFILE
default_profiles =('plonetheme.classic:default', 'plonetheme.sunburst:default')
return addPloneSite(
app,
site_id,
title=title,
profile_id=_DEFAULT_PROFILE,
extension_ids=default_profiles,
setup_content=False,
default_language='en')
The important part is setup_content=False.
There's no initial content, no portlet... nothing.
You may check this full working example in ftw.inflator -> https://github.com/4teamwork/ftw.inflator/blob/00b8b984e7dc1052a7fb94d2e82455a66b271da7/ftw/inflator/bundle.py#L23

There are a couple of ways of patching Plone to achieve this behavior by default.
One is by using z3c.jbot to override the following template:
Products/CMFPlone/browser/templates/plone-addsite.pt
The other is by using collective.recipe.patch in your Buildout configuration like this:
parts += patches
...
[patches]
recipe = collective.recipe.patch
egg = Products.CMFPlone==4.3.10
patches = ${buildout:directory}/patches/setup-content-false.patch
the content of the patch file is this (I would love to know how to get this without having to edit the output of the git diff command):
diff --git Products/CMFPlone/browser/templates/plone-addsite.pt Products/CMFPlone/browser/templates/plone-addsite.pt
index bc83eb0..3aebbfe 100644
--- Products/CMFPlone/browser/templates/plone-addsite.pt
+++ Products/CMFPlone/browser/templates/plone-addsite.pt
## -99,7 +99,7 ##
</span>
</div>
<tal:content tal:condition="not:advanced">
- <input type="hidden" name="setup_content:boolean" value="true" />
+ <input type="hidden" name="setup_content:boolean" />
</tal:content>
<tal:baseprofile condition="python: len(base_profiles) > 1">

Related

How to change the footer in DocFX?

Just hope to change the footer copyright info, generated by DocFX.
Here is what I have done:
Export template:
Run docfx template export default, get a folder _exported_templates\default
Change the footer partials:
The files I have changed are .\partials_footer.liquid and .\partials\footer.tmpl.partial
Use the updated template:
Run docfx -t _exported_templates\default.
Serve the site again
Run docfx docfx.json --serve.
But the update is not shown when I refresh the documentation page. Is there anything else I have missed?
Try merge step 3, 4 into: docfx -t _exported_templates\default --serve.
Explanation: If you open the build output in _site after step 3, you should find the footer is actually updated. In step 4, DocFX builds the site again before serving, so finally you find the original footer because this build doesn't use your customized template.
Another quick solution is to add _appFooter to global metadata in docfx.json like:
"globalMetadata": {
"_appFooter": "<span>Customized Footer</span>"
},
Full reserved metadata list can be found here: http://dotnet.github.io/docfx/tutorial/docfx.exe_user_manual.html#322-reserved-metadata
The easiest way to do this is to change the model directly. In your template, create a file called conceptual.extension.js and use the following code:
exports.postTransform = function (model) {
model._appFooter = "<span>Copyright © 2015-2017 MY COPYRIGHT<br>Generated by <strong>DocFX</strong></span>";
return model;
}

ZCML configuration conflict between Zope2 and another zope.* package

I have a Plone add-on with the following setup.py
setup(
...
install_requires=[
...
'zope.i18n',
...
'Zope2',
],
...
)
If I run bin/instance I get the following traceback:
File ".buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 1527, in resolveConflicts
raise ConfigurationConflictError(conflicts)
zope.configuration.config.ConfigurationConflictError: Conflicting configuration actions
For: ('utility', <InterfaceClass zope.i18n.interfaces.INegotiator>, '')
File ".buildout/eggs/zope.i18n-3.7.4-py2.7.egg/zope/i18n/configure.zcml", line 3.2-6.8
<utility
provides="zope.i18n.interfaces.INegotiator"
component="zope.i18n.negotiator.negotiator"
/>
File ".buildout/eggs/Zope2-2.13.22-py2.7.egg/ZPublisher/i18n.zcml", line 5.2-8.8
<utility
provides="zope.i18n.interfaces.INegotiator"
component="zope.i18n.negotiator.negotiator"
/>
If I comment out zope.i18n from setup.py, run buildout again, then the instance starts fine.
Surprisingly enough, both bin/instance files (before and after removing zope.i18n) are exactly the same.
So I'm sort of left clueless about what's wrong on defining something on setup.py that anyway the same version gets picked...
Last note, on the distribution's main configure.zcml I have this line:
<includeDependencies package="." />
Does this matter at all?
That seems odd?? obviously it's not possible to registry twice the same utility, but both packages do? I'm very confused about that. Usually you don't need the <includeDependencies package="." /> parts, since all components should be loaded by the plone entry point of z3c.autoinclude. I assume in a default plone environment, one of the components will not be loaded.
I checked in on a Plone 4.3.6... The Negotiator of zope.i18n is used.
So my best bet is, that your <includeDependencies package="." />, also loads the configure.zcml of Zope2, which should not happen.
Removing the <includeDependencies package="." />, may solve your issue.

How do you determine which theme you are on when ZSH_THEME="random"

I found a theme I like but only after executing a program on the command line with a lot of output, so I don't know the name of the current theme!
Here is the relevant part of my .zshrc:
# Set name of the theme to load.
...
ZSH_THEME="random"
Is there a way to determine which theme I am on?
According to oh-my-zsh.sh L81-87:
if [ "$ZSH_THEME" = "random" ]; then
themes=($ZSH/themes/*zsh-theme)
N=${#themes[#]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
Therefore you should be able to print the path to the random theme with
print $RANDOM_THEME
As it was requested to its developers team, a new command is added to support this functionality:
just use:
echo $ZSH_THEME
the response will be the current theme which is using by user.
To update the answer of #4a1e1.
The current version of oh-my-zsh has implemented a second option ZSH_THEME_RANDOM_CANDIDATES that works together ZSH_THEME
When
ZSH_THEME="random"
ZSH_THEME_RANDOM_CANDIDATES=("robbyrussell" "rkj-repos")
To each new terminal opening, only robbyrussell or rkj-repos themes will be applied.
In updated versions you can list the current theme using omz theme list. It will list the current theme as well as the available themes for oh-my-zsh.
io :: ~ % omz theme list
Current theme: flazz
Custom themes:
example
Built-in themes:
3den Soliah adben af-magic afowler agnoster alanpeabody
amuse apple arrow aussiegeek avit awesomepanda bira
You can use prompt -c which will print the current theme.
note: I am not sure from which version this is available, mine is zsh 5.8

Pagenumber format in rml reports in Openerp6.0

In rml reports how can i change the current page number format from page:1 ,page:2 etc to something different. For eg:
page:1/2 in the first page and
page:2/2 in the second page...
how can i do this ? i am using openerp6.0
currently i use the following code in the company page in the openerp interface to get the page number.
<drawCentredString x="18.5cm" y="1.5cm"> Page: <pageNumber/></drawCentredString>
This works for my OpenERP version 6.1.1
Changes was done in my Ubuntu server at:
/opt/openerp/server/openerp/report/render/rml2pdf/trml2pdf.py
Then restart openerp-server with following command:
sudo service openerp-server restart
my problem got solved just applied the below patch.
# HG changeset patch
# Parent 3fda5d5bbae001d42c56b5281e56fb2be0c8aa58
[FIX] use real page count for <pageCount/> flowable
diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py
--- a/bin/report/render/rml2pdf/trml2pdf.py
+++ b/bin/report/render/rml2pdf/trml2pdf.py
## -118,7 +118,7 ##
def draw(self):
self.canv.beginForm("pageCount")
self.canv.setFont("Helvetica", utils.unit_get(str(8)))
- self.canv.drawString(0, 0, str(self.canv.getPageNumber()))
+ self.canv.drawString(0, 0, str(self.canv._pageCount))
self.canv.endForm()
class PageReset(platypus.Flowable):

How to use a template in vim

This is really a newbie question - but basically, how do I enable a template for certain filetypes.
Basically, I just want the template to insert a header of sorts, that is with some functions that I find useful, and libraries loaded etc.
I interpret
:help template
the way that I should place this in my vimrc
au BufNewFile,BufRead ~/.vim/skeleton.R
Running a R script then shows that something could happen, but apparently does not:
--- Auto-Commands ---
This may be because a template consists of commands (and there are no such in skeleton.R) - and in this case I just want it to insert a text header (which skelton.R consist of).
Sorry if this question is mind boggeling stupid ;-/
The command that you've suggested is not going to work: what this will do is run no Vim command whenever you open ~/.vim/skeleton.R
A crude way of achieving what you want would be to use:
:au BufNewFile *.R r ~/.vim/skeleton.R
This will read (:r) your file whenever a new *.R file is created. You want to avoid having BufRead in the autocmd, or it will read the skeleton file into your working file every time you open the file!
There are many plugins that add a lot more control to this process. Being the author and therefore completely biased, I'd recommend this one, but there are plenty of others listed here.
Shameless plug:
They all work in a relatively similar way, but to explain my script:
You install the plugin as described on the linked page and then create some templates in ~/.vim/templates. These templates should have the same extension as the 'target' file, so if it's a template for .R files, call it something like skeleton.R. In your .vimrc, add something like this:
let g:file_template_default = {}
let g:file_template_default['R'] = 'skeleton'
Then create your new .R file (with a filename, so save it if it's new) and enter:
:LoadFileTemplate
You can also skip the .vimrc editing and just do:
:LoadFileTemplate skeleton
See the website for more details.
Assume that your skeletons are in your ~/.vim/templates/ directory, you can put this
snippet in your vimrc file.
augroup templates
au!
" read in templates files
autocmd BufNewFile *.* silent! execute '0r ~/.vim/templates/skeleton.'.expand("<afile>:e")
augroup END
Some explanation,
BufNewFile . = each time we edit a new file
silent! execute = execute silently, no error messages if failed
0r = read file and insert content at top (0) in the new file
expand(":e") = get extension of current filename
see also http://vim.wikia.com/wiki/Use_eval_to_create_dynamic_templates
*fixed missing dot in file path
Create a templates subdirectory in your ~/.vim folder
$ mkdir -p ~/.vim/templates
Create a new file in subdirectory called R.skeleton and put in the header and/or other stuff you want to automagically load upon creating a new ".R " file.
$ vim ~/.vim/templates/R.skeleton
Then, add the following to your ~/.vimrc file, which may have been suggested in a way by "guest"
autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.skeleton
Have a look at my github repository for some more details and other options.
It's just a trick I used to use .
It's cheap but If you ain't know nothing about vim and it's commands it's easy to handle.
make a directory like this :
~/.vim/templates/barney.cpp
and as you konw barney.cpp should be your template code .
then add a function like ForUncleBarney() to end of your .vimrc file located in ~/.vimrc
it should be like
function ForBarneyStinson()
:read ~/.vim/templates/barney.cpp
endfunction
then just use this command in vim
:call ForBarneyStinson()
then you see your template
as an example I already have two templates for .cpp files
:call ForBarney()
:call ACM()
sorry said too much,
Coding's awesome ! :)
Also take a look at https://github.com/aperezdc/vim-template.git.
I use it and have contributed some patches to it and would argue its relatively full featured.
What about using the snipmate plugin? See here
There exist many template-file expanders -- you'll also find there explanations on how to implement a rudimentary template-file expander.
For my part, I'm maintaining the fork of muTemplate. For a simple start, just drop a {ft}.template file into {rtp}/template/. If you want to use any (viml) variable or expression, just do. You can even put vim code (and now even functions) into the template-file if you wish. Several smart decisions are already implemented for C++ and vim files.

Resources