Showing posts with label zope. Show all posts
Showing posts with label zope. Show all posts

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?

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.

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.

Thursday, September 18, 2008

make SD dance your way

Singing & Dancing is newsletter package for plone3. and a powelfull one. its structure really shows the power of component architecture (CA). only thing missing is some nice documentation, that show customatization technics. did i mentioned that is really well tested (that reminds me that i owe some test for my last project).

when integrating S&D had to do this two customizations:
* include more then just title and description for collector items in newsletter mail
* when content is collected and sent, state of this content should change. so that next time wont get sent.

and before we dive into coding, you know what to do ... PFMO
(Put the Fuc#### Music On) - if your neighbours dont like it, change neighbours



adding image to "Latest News" collector
  • create custom item formatter implementing collective.dancing.IFormatItem



  • register adapter for newsitem content type



  • and thats it. when you collect news items our item formatter will be applied

Change item state after being sent
this is useful so collector does not grab items twice.
  • create newsletter_workflow. (definition.xml) to describe states in short:
    - pending (initial state): content is pending for review to be inlcuded into newletter
    - ready: ready to be collected ny newsletter
    - sent: content already sent

  • create "newsletter_item_already_sent" subscriber method for MessageChanged action



  • subscribe to MessageChanged action



  • now create collector that listens for "ready" state, and your ready to go

well thats about it, S&D is fantastic project relatively young, but is becoming more and more stable and feature reach. i could say its one of those tools in plone i really missed in the past.



resources:
- Daniel Nouri on "Composer templates, IFormat and IFullFormatter"
-
Zope Component Architecture

Tuesday, September 16, 2008

(repoze.)plone dependecy graph

while reading rss i found this post where there is a nice dependency graph for zope. plone was recently eggified (it will be released in 3.2 version, curretnly only in plone-coredev), but still its dependency in setup.py are missing. for this puporse i'll use repoze.plone package.

get some snack, put on the headphones, surf to your favorite radio and lets start the work...
  1. install repoze.plone

    rok@bestia ~/Projects $ virtualenv -no-site-packages repoze-plone
    rok@bestia ~/Projects $ cd repoze-plone
    rok@bestia ~/
    Projects/repoze-plone $ source bin/activate
    (repoze-plone) rok@bestia ~/Projects/repoze-plone $ easy_install -i http://dist.repoze.org/plone/latest/simple repoze.plone

  2. install eggdeps

    (repoze-plone) rok@bestia ~/Projects/repoze-plone $ easy_install tl.eggdeps

  3. install graphviz accordung to your distro. mine is gentoo, so i'll have time for making myself a coffee before graphiz is installed. someone will call that stupid and unecessary. i call it distro that likes me and makes computing fun again.


    # as root
    - python flag must be enabled
    bestia ~ # emerge -va media-gfx/graphviz

  4. ok i did't fetch coffee instead there is worm cocao'n'milk in my hands. now its time to produce some graphs.

    (repoze-plone) rok@bestia ~/Projects/repoze-plone $ eggdeps -d repoze.plone > repoze.plone.dot
    (repoze-plone) rok@bestia ~/Projects/repoze-plone $ dot -Tjpeg repoze.plone.dot > repoze.plone.jpg


  5. and voila our graph is here ... make you own judgement


maybe this graphs are not important, but i hope in next versions plone will become better python citizen and that i could install plone by simply doing "easy_install plone" and that its dependecy tree would be better looking, why? because style matters

garbas.forum 0.1b7 - released

lasts month i was mostly busy with exams and i pass know only one untill now. just before exams started i released 0.1b7. still there is quite a lot of work to make it to the rc1 but that does not intimidate me. you can expect more beta releases in next month and i hope to make rock solid rc1 until end of next month, when i'll make some announcement on plone.org/products

there are quite some, changes made from beta4, check them out here ...
http://pypi.python.org/pypi/garbas.forum
but there are some items in todo list that will change this forum up-side-down. some things you learn by doing them or next time i should plan better.

extra feature that i found quite interesting is commenting of images that also shows inside forums.
- you install garbas.forum
- in forum configuration panel select content type that you want to comment it. and also select to which forum should all this comments go to.
- when new comment is made new topic in forum is created with parent object's title as base of topic titile (eg. /ploneportal/galleries/my-new-house/image1.jpg will become /ploneportal/forum/my-new-house-image1.jpg)

Tuesday, August 5, 2008

where/how to learn plone?

i will assume that you already know how to click around plone, and you could easily be a site administrator for plone site. you also know how to change little things in ZMI, and you are familiar with TAL/METAL.

1. first you must read martins book "professional plone development" (there are guys on irc#plone already calling it plone bible). this will give you a nice starting how programming in plone looks like.
http://www.packtpub.com/Professional-Plone-web-applications-CMS/book

2. when you start digging around through code, a good starting base that you'll need is "A Comprehensive Guide To Zope Component Architecture". short but really nice book.
http://www.muthukadan.net/docs/zca.html

3. next book is about zope ... if you want to get into plone you must be familiar with zope. this is what i recomend
http://plone.org/documentation/books/web-component-development-with-zope-3-second-edition

*** till know i only read this three books about plone/zope, if you know any other please let me know. i would like to learn more if there is a chance.

4. most important reasourse after that were blogs of "senior" ploners. so subscribe to http://planet.plone.org/ ... and check it every day, you would be amazed how many usefull things this guys are talking about


want more? ... to be really 100% up to date ...
- usefull links to tutorials in one place (http://www.openplans.org/projects/plonecheatsheet/project-home)
- subscribe to mailing lists (http://plone.org/support/lists)
- be on irc.freenode.net#plone 24/7 and you'll see what good/friendly community is
- zope planet .... http://www.zope.org/Planet/
- python planet ... http://planet.python.org/
- dont forget to ask uncle google for help

Friday, May 16, 2008

virtualenv, zc.buildout or how to develop python apps

i hope i will get some responses of others and how you develop in python, what software do you use, so it bring your devel-deploy story easier.

1. VIRTUALENV
since your are in most cases working on several python apps that rearly have something incommon or they are suppose to work alone, is good the provide this application its own python environment. here you can use virtualenv and create virtual environment for out new app.

>> rok@bestia ~/Projects $ su -
>> Password:
>> root@bestia ~ # easy_install virtualenv
>> Searching for virtualenv
>> ...
>> root@bestia ~ # exit
>> logout
>> rok@bestia ~/Projects $ virtualenv --no-site-packages mynewapp
>> New python executable in mynewapp/bin/python
>> Installing setuptools.............done.
>> rok@bestia ~/Projects $ cd mynewapp/
>> rok@bestia ~/Projects/mynewapp $ source bin/activate
>> (mynewapp)rok@bestia ~/Projects/mynewapp $

and then to exit you virtualenv just do...

(mynewapp)rok@bestia ~/Projects/mynewapp $ deactivate
rok@bestia ~/Projects/mynewapp $

well thats it. you have a clean python environment (no other python packages), only setuptools is installed. and its ready to (ab)use it. its also possible to extend the creation of virtualenv with for example installation of your custom packages. only minus with virtualenv is that is not working under windows. well who is using windows anyway :)

2. ZC.BUILDOUT
its also a python development tool. and lately most popular egg in the cheeseshop, mostly because zope/plone ppl (like me) are using it for developing. it uses recipes which then installs your software, doesnt mather if its python app or some other app. by default you have some recipes that you can use, but its easily to write new ones.

!!! i use both virtualenv and zc.buildout for developing the same python app

>> (mynewapp)rok@bestia ~/Projects/mynewapp $ easy_install zc.buildout
>> (mynewapp)rok@bestia ~/Projects/mynewapp $ buildout init (or bootstrap if you already have configuration file)

then its up to you how/what you insert into your buildout.cfg. follow this link to learn more about the magic that zc.buildout does for you.

Thursday, April 24, 2008

where is the sun ... i guess i only need to open a window

Most of the work is being done to counter the effects of other people’s work: when we all agree to work half as much, the total result would be the same. (link)
i'm deep in work this days, so no time to write for my blog, but lets make an exception. lets stop working for 5min.

so here are quotes/links of today that made my day or i just found them intersting:
  • i hope to found sponsor to go to washington to plone conference 2008, well anyway there is a survey about it and i enchourage to you to fill it (link)
  • this just shows other that python is a great tool "Jansen says not much has affected the top ten programming languages in the last five years, with only Python entering the top 10 (replacing COBOL),.." (link)
  • quoting bill gates: 'there is this thing called the GPL, which we disagree with.' Open source, he said, creates a license 'so that nobody can ever improve the software,' he claimed, bemoaning the squandered opportunity for jobs and business.' (more)
    well what can i say ... its bill gates ... as my imaginary acient africant philophist says:
    "dont brag you can fart a lot, because diaria is around the corner."
  • A fourth award for PloneGov (link)
    This new prize highlights one more time PloneGov avant-garde. The PloneGov initiative, started mid 2007, already won 3 other awards:
    - Paris, Grand prix du Jury, Lutèce d'Or 2007
    - Lisbon, Finalist, European e-Government Awards 2007
    - Brussels, Good Practice label, e-Practice 2007
    The "Prime Minister Public Service Excellence Awards 2008” outlines the outstanding quality achieved by the Irish PloneGov branch.


and yes i opened a window and there was sun.... lots of it ... sometime you forget to open it and you think world is small, well its not...

Saturday, April 19, 2008

goodbye macros, hello content providers

i want to refresh main content area in plone with kss. but here comes the problem. you can only refresh content providers - viewlets, portlets - with kss. making another viewlet manager and then another viewlet inside is not smelling nice. for sure there must be a better way of doing this.

[1] after a day of browsing on the net i found the solution. creating another content provider and then calling it from where ever (eg. main_template) is so simple that i think plone developers should use it more often.

content providers = zope piece of content to be shown on a page.

EXAMPLE
how to create and register content provider. packages is called "garbas.firstpage".


then you simply call you provider from any other template using
< tal:replace="structure provider:garbas.firstpage.firstpage" /&rt;


next time i'll show how to benefit from using content provider with kss. stay tuned ...


[1] http://wiki.zope.org/zope3/FAQConfigurationAndSetup#how-can-i-register-a-content-provider-without-using-viewlet-managers

Monday, April 14, 2008

where zope fails the most

ok, i'm not some big expert in zope, but some things are really bugging me about zope. zope is really nice tool, if you know how to use it. but mostly ppl get scared when they see zope.org. site is in really bad shape. common guys. such a nice code, but so horrible site. i'm not talking here about design, i'm talking about how a simple person (small town programmer) can find anything on that site. that site should also, by my opinion, promote all those useful - non zope related - packages (zope.interfaces, zope.component, ...). my user experience with zope.org is really bad. its really hard to find something on that site, well after time you get used to it, but still when i see the link referring to zope.org, i get scarred about loosing another hour.

it's maybe not that bad as i said before, but still i see zope.org as one of the biggest black spots in zope world.

for now i really dont like this blog post, mostly i complain, makes me feel like my friend's wife. well i guess it would be nice to write some solutions for this problem:
  1. show more clearly that zope (3) is going more python way, i really like plone.org first page and that tabbed presentation of plone. it gives visitor quick overview of plone. zope should have some similar quick presentation of what zope can do.

  2. documentation should be better categorized. so you could quickly found all the documentation/tutorials/howtos about you problem. there should also be a mark for outdated documentation. i'm also missing commenting on howto's.

  3. i think there should be a section totally devoted to WSGI. here i mean middleware of all kinds. repoze.org ppl should be in-charge of that section. they are doing excellent work. all in all wsgi is pythons web future.

  4. ok also some design work should be done, so its more clear and user friendly to use, but hey, thats only my opinion.

in short that would be it ... maybe i'll come up with something tomorrow, but i would really like to hear what all other zope (ab)users think about zope.org. was there already some discussion about this that i missed. i just recently (last 3 months) subscribed to zope, plone planets so i should maybe not judge this.