Eclipse bundle: build your own

Posted in eclipse, makina-corpus on March 18, 2009 by toutpt

Remember an old post i have done about the way i manage eclipse third part plugins dependencies, i have discover a web site where you can select the plugins you want and it build a bundle for you ready to be downloaded:

Yoxos eclipse service

I have tried it and it rocks ! For 131 MO to download i got:

  • Pydev
  • WTP (XML + JS + …)
  • Git plugin
  • Mylyn + Mylyn connectors for Track and Mantis
  • AnyEdit (manage tabs and spaces)

And you don’t have all Java’s stuff in your eclipse so it’s stay clean and start quickly.

Plone and local roles, too quiet.

Posted in makina-corpus, plone on March 14, 2009 by toutpt

I have work hard on testing/debugging an already developed specific app that handle local roles in a Plone site. I was sure that local roles was just manageable throw a permission but i have finally read the code that handle local roles and understand things:

* you can only add a role to somebody if you have the permission “Change local roles”
* you can only add a role to somebody if you this role in that context
* role are quiet on error (if you don’t have the role you are trying to add, you will not have any log)
* if you have manager role you can do what ever you want (don’t do your tests in manager !!! )
* else candidate local roles are only yours without ‘Anonymous’, ‘Authenticated’ and ‘Shared’
* local roles are stored in a dict called __ac_local_roles__ on the context

After one day of work with local roles, i think the most painful part is to don’t have log, even in debug mode. When a process is called to do a job and it do half of it, i think it has to said something.

But local roles are an essential part of Plone that i really like.

PS: i have discover to late a good module to display local roles in Plone: zopyx.plone.cassandra.

i m switching from SVN to GIT

Posted in git, makina-corpus, tools with tags on March 7, 2009 by toutpt

yet an other post to say svn sucks. yes it is. But many people who use svn are happy with it and i was happy to.

It’s hard to maintain a trunk when 5 people are commiting on it during the project life. So i have started to look at DVCS (git hg, bzr). I have tryied GIT because of it’s popularity.

At work, someone is using mercurial (hg) and we are two people intersting in GIT. So i have decided to test it but over SVN. it means the central repository is still an svn one.

Here is the way i m using it:
1. clone the repo (git svn clone blabla)
2. branche
3. work on your code (commit, …)
4. merge on master
5. git svn dcommit

And you get it, only one commit on the trunk (master) and the power of git to merge, commit, …

Some cool features and properties of git:

  • space on hdd of a git clone < svn checkout (and you get the all history
  • fast, git is damn faster than svn. When you type enter key, you get it (except from git svn clone, because here it’s svn)
  • qgit2 (qt4) is a very good tool (you can browse your svn history, look at diffs, ….)
  • the help on command line. git status give you help for next command you will make

But there are some point i have not found handy:

  • git st mygitrepo/ doesn’t work (”is not a git repo” but it is)
  • no default alias (st, co, …) but can be easily configured
  • svn externals can be seen has submodules, but no managed in that way. git svn do not handle svn:externals and you can’t use git submodules over svn
  • eclipse do not manage git (and i know it s a pain for eclipse guys because it break the way plateform is thought)

I hope all that things will be improved in the futur of git, but now i m using git at work. Next step will be code review TTW.

build a zope 3.4 with Postgresql and YUI framework & get ready to work with

Posted in makina-corpus, python, zope on March 3, 2009 by toutpt

I just want to try to make a simple application with the best of current opensource technologies. Got a try with those one:

  • Python 2.5
  • Zope 3.4
  • Postgresql 8.3
  • SqlAlchemy 0.5
  • YUI 2.7
  • ZODB in Postgresql with RelStorage

I have take an hour to install this on my laptop, with the excellent virtualenv to build a copy of an already installed python in a directory.

/path/2/python/bin/virtualenv --no-site-packages /path/2/project

Next i have use zopeproject to install the last zope3 technologies. Now zopeproject use the KGS to set the version of eggs to use.

cd  /path/2/project
source bin/activate
easy_install zopeproject
zopeproject myproject

You get it, you have the last release of zope3.4 release. Now add the eggs you want to use

eggs = ...
       psycopg2
       RelStorage
       ore.alchemist
       hurry.zopeyui
       z3c.form
#       chameleon.zpt require zope.i18n > 3.4

modify your zope.conf to configure RelStorage:

%import relstorage
<zodb>
  <relstorage>
    <postgresql>
      # The dsn is optional, as are each of the parameters in the dsn.
      dsn dbname='zope' user='zope' host='localhost'
    </postgresql>
  </relstorage>
</zodb>

Now, you get your zope3.4 running on python2.5 and store the zodb data in postgresql. I have lost most of the time on RelStorage and postgresql configuration. I’m to work with all those technologies.

I will work on making a simple blog in pure zope3, and next i will try to make the same application with SqlAlchemy.

Archetype_tool, QueueCatalog, becareful with indexing with Plone’s portal_catalog !

Posted in makina-corpus, plone on December 14, 2008 by toutpt

The portal_catalog in Plone is the index of all objects. It means the portal_catalog store some datas (indexes+metadatas) per object in the website. So when the number of entries in the site grows up, the portal_catalog size follows. The post by tarek Indexing explain it well:

50% of the size of the ZODB was the catalog (I am talking about gigas here)

And that is the case for some website i m working on

If you are storing about 10 indexes and 10 metadatas in it. the size of a brain with indexes for one object is not so far from the real object (brains are persistent object stored !). So if you are about to add an index, or a metadata think about it twice before doing so.

But as me you want to be able to index a new data from my new content type to search for objects that match to your criteria . For example you have a type “Contact” with a field “EMail”. Many developpers will just adding an index getEmail in the portal catalog. Please don’t do it! Just adding a new catalog tool inherited from CMFPlone CatalogTool, and changing the init index method (Plone2.5 doesn’t support well the generic setup way of managing catalog index and metadata). Next add path index that is needed by the Archetype CatalogMultiplexin class to reindexObject, and register this object in the archetype tool so it will be automaticaly synchronised with the new catalog.

You can query that new catalog like the portal_catalog, and  if you don’t want to wake up the object and get the metadata from the portal_catalog, just do a query to the portal_catalog by using the path index. Recently i have totaly remove a content type from the portal_catalog. That has been possible because this content type was not displayed throw classic plone folder_content view. As results 30 000 brains has been removed from the portal_catalog.

Think about why you will add an index in portal_catalog. Every object in your web site has that field or are supposed to be able to have it ? if you answer yes, you can. A good example is a rating information, If you want to be able to sort results on it, you must use the portal_catalog.

An other things very important about indexing with Plone is about full text indexation and is for performance purpose. As you will find in mailing list, lot’s of people are complaining about ZCTextIndex. They are slow ! I have done a bench this week with PloneQueueCatalog and factory hack. I have delayed every ZCTextIndex, and put a pyston timed decorator on indexObject, reindexObject and unindexObject of CatalogMultiplexin class. The results was:

  • 0.039 seconds with ZCTextIndexes and 0.025seconds with ZCTextIndexes delayed on the last indexObject call.
  • 0.5sec for not interesting index+reindex+unindex in portal_factory without factoryhack , and 0.11sec with the hack. This one has not been improved by QueueCatalog.

The portal_catalog has 130 000 objects indexed, and the data.fs is about 1.3GO. This bench has been done on my laptop (IntelCore2 duo + 2GO RAM).

So now i m using those products in production now.

TESTS PURPOSE: I would like to make a relational database to replace the portal_catalog. Now postgresql support for full text indexing, and it will be pretty easy to return basic objects that will use results from sql query as attribute. With a good JMeter test plan to see results. If anyone has already done that kind of test i m really intersting in this, please tell me.

A word about lorem ipsum (aka lipsum) generator and Python

Posted in lipsum, makina-corpus, plone, python, selenium on December 10, 2008 by toutpt

Today i have made some fonctionnal tests with lorem ipsum text generator for Plone Selenium. The first thing i have done is to search for a python script to make text generation a la lipsum.

I have been surprised by the fact most of scripts i have found use text alerady generated. It s the case for :

But on the official web site we can find a python script : pypsum. I have used and derived that one to generate CSV file by that way:

python data_csv.py -a 10 -f paras:3:texte_paras:1:description_words:5:title -d articles10_20081210_02.csv

And then:

python selenium_html.py -c articles10_20081210_02.csv -d articles10_20081210_02.html -o addArticles
You can find all my tests here

For sure it’s Plone specific code for the selenum part, but i m pretty happy of the result. I can now create random content for any website very quickly.

JMeter, improving performance of a Plone web site

Posted in makina-corpus, plone with tags , on October 13, 2008 by toutpt

Last week i have made a rush to improve performance of a Plone based web site. For performance testing i have used JMeter, because i have seen Using open source tools for performance testing

JMeter is really nice to use. Just launch it’s proxy, plug your browser on it, and do your test. Next you save it as xml and you can edit the test. So you can login (it support cookies) you can create content (with an once logic controller) consult content, and stress your server.

What i have learn from this about Plone is:

  • Do not use brains or any object in templates, or you will not beeing able to cache your logic code in ramcache. Use dict that contains every strings ready to be displayed in the templates.
  • How to use the ram cache
  • i can store acl_users in ramcache, and i have been surprised to see the difference. On 5 tabs hitted, i have hit the cache 278 times …
  • Archetypes is damly slow (about one second to set some attributes of an object in a btree and reindexIt)
  • CMFPlone.utils.createObjectByType do a reindexObject
  • Do not add any index to the portal_catalog, use the buinding done by archetype_tool to be able to use other index. I m adding about one catalog tool per custom content type.
  • A query on the portal_catalog can take one second if you have for example a list of 100 paths (query['path'] = ['/first/path', '/second/path'] and more than 100 000 entries.

I have learn many other things during the last week, but now i m using stress tests during the dev

Look at my profile

Posted in makina-corpus, plone on April 13, 2008 by toutpt

First of all I would like to thank guys who wrote GenericSetup. I m writing this post cause i think profiles are not well used. They are used like Extensions/Install.py scripts. So what is a profile, and how to use it ?

Profile is about configuration of portals (portal_xxx inside the zmi). In that way I have started by asking myself “what means install/uninstall in Plone” ? Some answers:

  • “its about the Extensions/install.py scripts.”
  • “Like on your computer, you install a software or a lib”

Well, there is no sens for the word “install” in the world of plone. We are speaking about configuration of tools. So the CMFPlone/profiles/defaults, contains a plone default configuration. Right ?

In that way extending default plone configuration means, change it a bit, adding some directory views in portal_skins for example.

What happens if you are “installing” 20 products to you configuration ? Here it is ! You have lost the configuration of your Plone project and will not be able to understand why this new product you are trying to install break your website.

Seeing this, I have proposed to add one single profile by project. In that way you controle your entire Plone, and if you have a problem, you just have to apply this profile. But that also means you have to write it. Here is how i proceed:

  • Install every product you need
  • Export all steps
  • Adding a new product/egg specially for your project
  • Put the results of the exports in it
  • Read it,
  • Add all constraints in it. For example the order of layers inside skins.xml

This is done, you get it ! There is no duplication of files, but integration of products inside Plone configuration (my work). Writing XML is boring ? Writing them faster by using my eclipse templates ;)

The next point is about setup handlers. I hate product that add setup handler just to say “hey i know how to add a step”. I always ask for “what is a step for you ?” So steps are not the way to call a python script. If you are tented to add a step, just use Extension/install.py to put your script. Adding a step make sens only if you are adding a tools, and you want that tools to be configurable. So you don’t add setuphandler.py but you write import/export.py for your tool, and then you adding the step with import_step.xml.
An other problem is the configuration of your Plone project can be different for a production server and developpement local server. For example the mailhost.xml file can be different. In that way you can extend your profile with just a smaller profile that reconfigure what you need.

This is why i m laughing when i heard “uninstall profile”.

Finally, i don’t understand why the portal_quickinstaller is now “aware” of extensions profile. That doesn t help to understand profiles. People will continue to write install/uninstall profiles. If any one know why i m ready to discuss about it.

My point of BrowserView

Posted in plone on April 13, 2008 by toutpt

Since Plone2.5 has been released, there is a good way of seperate logic and presentation from templates, but the use of BrowserView is not used in the same way by developpers. i m trying here to explain my point of view about that component.

A very good presentation of BrowserView is already done by Optilude;

According to my point of view and the MVC pattern, a BrowserView is just a controller. its role is to prepare data to be displayed, or to trigger a process. Most of the time i m querying the portal_catalog, redirect the user, add status messages, ….

I like the way portlets are done under plone2.5. for me it s the best example of how to use BrowserView.

The other use case of BrowserView is to render the attached template and insert a “view” instance in it. This is a kind of “implicit” behaviour that i hate in zope2. So you can call it directly by the url. I don’t understand that choice, but Plone3 use it in that way. And that do not let you reuse the logic code inside the BrowserView in an other template. Controller is known to be reusable throw the entire software.So please, use the BrowserView component like a controller.

ReferenceEngine and poor Archetypes

Posted in plone on March 7, 2008 by toutpt

Today, got a bug on custom content type. “I can’t copy your content type, all the references are lost”

Well, i assume i don’t know how copy / paste works in plone. I first reproduce the bug without a pb:

  • Create two documents : a and b. set related document from b to a. means b has related document a. the field relatesTo is a ReferenceField.
  • Make a copy of b, said c.
  • Oh !!! c has no related document.

The bug is reproduce: ReferenceField doesn t support copy . Now i know that, i m starting to read all i found about References in Archetypes, and find this in Referenceable.py:

####
## In the case of:
## - a copy:
##   * we want to lose refs on the new object
##   * we want to keep refs on the orig object
## - a cut/paste
##   * we want to keep refs
## - a delete:
##   * to lose refs
####

So this is not a bug but a feature ? Don’t be disapointed, Plone is build to be customized. CopySupport comes from zope, ok interesting code out there. I m finally try to MonkeyPath the methode manage_afterAdd and succedd in keep the reference:

## OFS Hooks
def manage_afterAdd(self, item, container):
    """
    Get a UID
    (Called when the object is created or moved.)
    """
    print "Referenceable manage after add"
    isCopy = getattr(item, '_v_is_cp', None)
    if isCopy:
        setattr(self, config.UUID_ATTR, None)
        self._delReferenceAnnotations()

Every things ok ? Well no, in fact, i m trying to validate by retry the scenario above. c document has the related document to a. good, but i next delete c and that action delete the b relation with a (b doesn t have relation with a anymore). And Archetypes team writes ## * we want to lose refs on the new object ??? You call this a feature, i call that an error of referenceengine design !

Thank you Archeytpes !

If anyone know how to fix this i m ready to listen :)