Friday, November 21, 2008

plone-coredev with git (recursive svn:external solved)

months ago i migrated my projects to git. i wont go into debate why git, maybe this is for another post, but one of reasons was that it also seemlesly integrates with subversion. so you can use git on svn repos too.

if you are an old svn user and want to give git a try here is a nice tutorial with comparison to svn commands (http://git.or.cz/course/svn.html). there are also other good tutorials on the web, uncle google is the guy to ask.

there were some cool changes in plone-coredev/trunk lately so this is a reason more to give it a try. but ofcourse i'll use git. there are many svn:externals which git-svn does not support but there is a workaround ofcourse. so lets start...

rok@bestia ~/Projects $ git svn clone https://svn.plone.org/svn/plone/buildouts/plone-coredev --trunk=trunk --branches=branches --tags=tags --revision=21212:HEAD
rok@bestia ~/Projects $ cd plone-coredev


this only pulls buidlout from svn, svn:externals are not pulled out. now we use git-externals script which will pull svn:externals.

rok@bestia ~/Projects/plone-coredev $ ./path/to/git-externals
... fetch a coffie/tea/beer this will take time ...
rok@bestia ~/Projects/plone-coredev $ virtualenv-2.4 --no-site-packages ./
rok@bestia ~/Projects/plone-coredev $ source bin/activate
(plone-coredev)rok@bestia ~/Projects/plone-coredev $ python2.4 bootstrap.py
(plone-coredev)rok@bestia ~/Projects/plone-coredev $ buildout -v
(plone-coredev)rok@bestia ~/Projects/plone-coredev $ instance


and you have plone-coredev/trunk running... from first tast ... its fats :)


so what that does that git-externals script do?
its a script i wrote today, probably is buggy as hell but it works for now. it clones svn:externals in place they should be. in every package that has svn:exernals, .svn-externals file is created. reason i created it is because i didnt found any that can handle svn:externals recursivly. so here it is, ... http://github.com/garbas/garbasgit.svnexternals/tree/master/git-externals

if you have any ideas, wishes, suggestions just write on rok-dot-garbas-at-gmail-dot-com.

Wednesday, November 19, 2008

z3c.form in viewlets

i blame hannosch for not to be able to sleep tonight :P (previous post)

my obstacle today/tonight was z3c.form+viewlet coctail. after 2h of testing and optimizing i got quite nice peace of code:



and layout_viewlet.pt



now instead of wrapping with FormWrapper we wrap with our new ViewletFormWrapper, like:
OurViewletView = wrap_form(OurCustomZ3CForm, __wrapper_class=ViewletFormWrapper)

all that is left to do is register OurViewletView with browser:viewlet directive and form is ready.

i found this wrapper really usefull and i hope it can get into plone.z3cform. or is there any other way of doing this?

my plone wish list

i just read hannosh's "News from trunk ..." before going to bed and as a result of this i woke up in the middle of the night (its 2:30am here) to write this blog post. i will just write things that i wish would be in plone4. some of this are unpolished ideas, some of this are just pain that i'm expiriencing.
  • everything is a folder (no folder content type)
    idea is not new, its taken from limi's blog, but everything (except File, Image) content types should be folderish.

  • no Image content type
    well Image is nothing more then extended File content type. what i saw in past was that users were confused that there are so many content types. by having only one content type it make plone even easier and close to file-like-system.

  • small/tiny/micro plonecore code base
    when plannning next release please also consider developers happiness not only end-users. we are ppl too you know :P. what i mean is that 90% time i work with plone i really dont need all those features that are builtin. 90% time i need only 2 content types (Document, File) which i extend, superclass, ... this is again subject to argue about, whether plone is framework or software. why it couldnt be both? having light plone core which developers could use to build on it, and end users ready packages like plonefor.community (curent plone), plonefor.getpaid, plonefor.goverment, plonefor.education, ...

  • link content types, wtf?@#$%
    maybe i should read some more end user doc but i just dont get what with link content types all about. just to store link to some page. i would expet form it to show content inside plone (like Windowz product), redirect to that link or even both options. but ofourse this is something that should not be in plonecore (menitoned above).

  • portlets+viewlets=widgets (or call it as you want)
    again idea is nothing knew. all i would ask from plone4 is that it provides rock solid UI to manipulate with them. draging and droping please.

  • no XML please
    i use genricsetup in day to day basis and writing all that xml is just not fun you know. we use perfect language - python - if you forgot. use it. it can do more then just magic. sonce XML is only computer friendly and if we really must use xml then an UI tool *must* be provided or if not next plone book should be "pistol for developers included - for self puprose only"

  • unified plone registry
    this has nothing to do with windows registry so dont panic. its just some centralized way of storing site configuration that can be also (ab)used by add-on products. now we have a mess. every configuration is stored in its own way and place.
    if i may dare this could also be next-generation of genericsetup (with no usage of XML ofcource).

  • no kss in plonecore, ship only with jquery
    50% of time i disable kss since it slows down the site. yes kss is usefull but not in all scenarios. make developers choose whether they would like to write javascript or use kss.

  • developer reference documentation
    this should be killer feature of plone4. currently there is no - or is really in bad shape - reference developer documentation. Christopher Warner few days ago wrote "If core code is undocumented it's broken". but who should be responsible for this? core developers. when there is new feature added/removed documentation should be alsoo updated. sphinx here offers a great way to document our code. it can be api, doctests, docstrings all in one. and can be done from the code ,so all those doctests, docstrings that are already there will be used.
--- after a while i found some more ---
  • plone theming
    deliverence promises a lot, but still plone itself must provide easier theming expirience. something as easy as old zope2 skins and scalable/reusable as zope3 resources.

  • wsgi out-of-the-box
    this is a must, repoze middleware that is availiable now looks so usefull i'm just wainting for some project to try it out.

well this is it, for now ... i'm exited with plone4 release and now its time for me to go back to bed. i think by the end of this night i'll come up with few more.

Wednesday, November 12, 2008

one week of riding sphinx

i made 3 releases today to pypi:
  • SphinxBuilder
    buildout recipe for sphinx. that way writing/deploying sphinx docs becomes easier. initialy code was written by tarek i brought it from 0.1.2 to 0.2

  • AutoATSchema
    extension for sphinx which documents archetypes schema automaticaly
    example:
    .. collective.sphinx.autoatschema:: my.packages.content.mycontent.MySchema

  • IncludeDoc
    another extension for sphinx which includes doctest from also other packages.
    example usage:
    .. includedoc:: my.package:/relative-to-package/path/README.txt
inititaly i start looking into sphinx to see if also plone can also benifit from this usefull tool. i'm still doing research and will shortly publish my results and my ideas how to use sphinx in plone process.

i must mention that work on SphinxBuilder and AutoATSchema was sponsored by Headnet. thank you Headnet.

where to go from here?
you can see work in progress for possible replacement of api.plone.org. well its only research so currently only tree packages are there: plone.contentrules, Products.Archetypes, Products.ATContentTypes. there are a lot of stuff missing consider it as staring point.
http://docs.garbas.si/plone-latest

why i think sphinx is the right tool for api.plone.org?
  • definitly *not* because sphinx is new hot stuff, but because of its features and because it makes can integrates well in plone proccess
  • very few ppl uses api.plone.org because of its current state. plone was by some extend ment to be framework and frameworks needs good, clear api so new developers can "plug-n-play"
  • we all know that api is not the strongest point of plone. well i could criticise it, but that wont change anything. with sphinx we can hide bad api parts or emphasise good / useful ones.
  • best / up-to-date documentation can only be written by core developers at the time of development (and maybe reviewed by doc team). well maybe not only but is sure the easiest way for all. we all are aware of TDD, there is several very well writen doc(test)s, but hidden from eayes of public.
  • because i think this can be the stongest feature for plone4. yes, having up-to-date documentation can do magic or at least attract more developers.
wanna help?
join us at http://www.openplans.org/projects/plonedevdocs where we brainstorm about possible options.

Thursday, October 30, 2008

strange "decoder jpeg not available"

well its obious what is wrong. pil was not compiled with jpeg support.

i'm currently setting up plone buildout on some centos box (for gentooista - like me - this is like having only one hand to type). i created virtual environment with --no-site-packages as usual. that means i need to install pil manualy.

?> wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
?> tar zxvf Imaging-1.1.6.tar.gz
?> cd Imaging-1.1.6
?> python setup.py install

the i've looked at build summary
--------------------------------------------------------------------
PIL 1.1.6 BUILD SUMMARY
--------------------------------------------------------------------
version 1.1.6
platform linux2 2.4.3 (#1, May 24 2008, 13:57:05)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)]
--------------------------------------------------------------------
*** TKINTER support not available
*** JPEG support not available
*** ZLIB (PNG/ZIP) support not available
*** FREETYPE2 support not available
--------------------------------------------------------------------


well next steps were obvious. i need to install libjpeg, zlib and freetype2, and then reinstall pil.

?> yum install libjpeg-devel zlib-devel freetype-devel
?> python setup.py install

and build summary is now
--------------------------------------------------------------------
PIL 1.1.6 BUILD SUMMARY
--------------------------------------------------------------------
version 1.1.6
platform linux2 2.4.3 (#1, May 24 2008, 13:57:05)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
--------------------------------------------------------------------


so i installed it right? WRONG!! if you test you plone instance you'll see that you can not upload image. even deleting pil from site-packages and reistalling didnt helped. problem is that you need to have fresh unpacked (untouched) version of pil when you install it.

?> cd ..
?> rm Imaging-1.1.6/* -R && rmdir Imaging-1.1.6
?> tar zxvf Imaging-1.1.6.tar.gz
?> cd Imaging-1.1.6
?> python setup.py install


i think i saw some guy/girl asking ppl on #plone why there is no pil support even if build summary shows that there is. well i think this was the case or at least this save my day.

Tuesday, October 21, 2008

my favorite buildout recipes

i'd like to share my experience with recipes. which one i use and which i found very exciting. and for the end which recipe i miss.
  1. zerokspot.gitrecipe
    since git is dvcs of my choice this recipe provides nice integration with git, when my code is not published yet.
  2. collective.buildbot
    i must admit that i didnt have chance to setup it up and give it a test. i heard ppl are really satisfied with it. well why shouldn't they be, setting up buildbot is super-easy now. i'm just searching time to setup buildbot to monitor my published projects.
  3. collective.recipe.backup
    use it constantly really useful recipe for your production. i would say this is a must in your production configuration.
  4. collective.recipe.sphinxbuilder
    great recipe for building your plone documentation with sphinx. it has some problems with recent 0.4.3, but i prepared some patch for it (need to tell tarek about it), should be included in next release.
  5. collective.recipe.supervisor
    i didn't use this recipe, but could become next thing to ship my deployment configuration with. i use simple (bellow) zc.recipe.egg:scripts recipe to ship with supervisord. then i have configuration files for supervisord separated from the buildout configuration, which is not so nice. for my next deployment i'll definitely look into this.
    [supervisor]
    recipe = zc.recipe.egg:scripts
    egg = supervisor
  6. gocept.nginx
    since i use nginx in 99% of my cases i like to ship also the configuration code for it within the buildout.
  7. iw.recipe.sendmail
    just found out about this one. i always add sendmail configuration code inside project i use which is then hard to switch to developing environment. well from tomorrow on i'll be using this. this is useful when you want to deploy Singing&Dancing with plone.
  8. plone.recipe.deliverance
    i'm really sorry not to have time to test this nice recipes. deliverence is "next plone generation themeing engine". i read all the docs/tutorials/reviews i could found about deliverence. i hope there will be some project in future that i could try it. maybe this recipe will make me try it since configuration is really easy.
  9. plone.recipe.varnish (plone.recipe.squid)
    i use varnish, but heard really nice words from ppl using squid. configuration of this to recipes is not similar, but is *identical*, so i might give squid a try just from my own curiosity . but before that i would need to learn some more about catching in plone. this is the area i lack knowledge most.
i also found more recipes which i didn't have time to look closer into. i'll just list them for me to test them later. if you used some of this please share your experience.
well i spoke till now only about what recipes we already have. but there is one recipe i would really like to see.

since i'd like to provide client with up-to-date, bug less as possible code in short time and not to wait for next releases of packages i often patch them. it would be nice to have this kind of tool possible to use from within buildout. maybe this will speed up (or at least make it easier) patch testing in plone core development. that would maybe lead to patches tested not only from one person but from more, maybe this patches are already used in production environment before they reach plone core which is big plus i think. so to sum up: recipe (collective.recipe.patch) that would apply patch to certain python package version. possible to pin this patch to specific version of python package)

maybe tonight is the night to produce this recipe. lets go cooking...

Sunday, October 12, 2008

generate your own z3c.form docs

recently http://www.carduner.net/docs/z3c.form/ was down. for some of us who are using it extensivly that was just like someone pull a hat over my eyes. well since z3c.form ppl are using sphinx to generate this lovely documentation you can also create it on you own.

rok@bestia ~/Projects $ svn co svn://svn.zope.org/repos/main/z3c.form/branches/pcardune-sphinx z3cform-doc
rok@bestia ~/Projects $ cd z3cform-doc/
rok@bestia ~/Projects/z3cform-doc $ virtualenv --no-site-packages ./
rok@bestia ~/Projects/z3cform-doc $ source bin/activate
(z3cform-doc)rok@bestia ~/Projects/z3cform-doc $ python bootstrap.py
(z3cform-doc)rok@bestia ~/Projects/z3cform-doc $ buildout

(z3cform-doc)rok@bestia ~/Projects/z3cform-doc $ docs
(z3cform-doc)rok@bestia ~/Projects/z3cform-doc $ firefox parts/docs/z3c.form/build/index.html

and you have it, simple a? this is the way official plone documentation should be, by my opinion.


problems?
z3c.recipe.sphinxdoc have some dependecy problem so you might have outdated email python package. if your buildout fails just update it with "easy_install email" and rerun buildout.