Showing posts with label plone4. Show all posts
Showing posts with label plone4. Show all posts

Sunday, April 24, 2011

Creating new content types using Dexterity for Plone 4 on OS X

update: These steps should work with little adjustment on a Linux base OS also.

This is a short write-up that helps you to quickly jump to the "important" section of the dexterity manual (http://plone.org/products/dexterity/documentation/manual/developer-manual/schema-driven-types/referencemanual-all-pages). Hopefully this will minimize some of the fumbling on OS X (and Linux also). I provide some boiler plate code that should help you to skip some of the initial coding and hopefully save you some trivial errors.

I'm assuming that you already have dexterity configured to work with your Plone 4 instance, if you don't go and read Get Started with Dexterity Development for Plone 4 on OS X. I also assume that you have a working version of git, so ensure that you have a working installation of git.

Back already? Great!

Through the Web (TTW) Content Types (Warm up exercise)
This exercise will help you to appreciate some of the principles associated with dexterity based content types in Plone.
Start your Plone instance
Then go to 'admin' → 'Site Setup' → 'Add-ons', check 'Dexterity content types' and click 'Activate'.


Now go back to "Site Setup", select "Dexterity Content Types" and start tinkering with it.


Then create a new content type called 'Person'. You can do this by clicking 'add new content type' (see the screencast below):











That's it.

Creating a content type with filesystem code
Now that you've seen the through the web (TTW) approach, let's look at storing code on the filesystem. The filesystem based approach is better for version management (e.g. with git) and redistribution of the code.

To make your life easier, I've created some boilerplate code based on the dexterity manual. The instructions below will get you started quickly (assuming you already have Plone and git installed).

Step 1 - Get the example configuration file:
Get the 'example.conference.cfg' from here and place it in the same folder that contains your buildout.cfg.

Step 2 - Update buildout.cfg to use the new configuraiton file:
The changes will look something like this;

extends =
base.cfg
versions.cfg
http://good-py.appspot.com/release/dexterity/1.0-next?plone=4.0.5
example.conference.cfg

eggs =
Plone
PIL==1.1.6
plone.app.dexterity
example.conference

The re-run buildout:

bin/buildout

Step 3 - Customize the example.conference product with new content types

Add 3 new files to src/example.conference/example/conference, presenter.py, program.py, and session.py.

Step 4 - Register the new content types as Factory Types

Once you've done this you should now be able to install the conference management system and add new programs, sessions and presenters, to your Plone site.

Get Started with Dexterity Development for Plone 4 on OS X

update: I've updated the steps so that they work for OS X 10.5 and 10.6 as well.

For this recipe you'll use:
  1. OS X 10.4 or better with XCode installed
  2. The Plone Unified installer (latest stable version 4.0.5)
Estimated time: 35 minutes
Remember to get XCode installed before trying any of this.

While I'm sure there are faster ways to get this done, I think this approach requires the least number of steps and gives you a working development system. This is also easily adapted for a Linux platform.

Step 1 - Get Plone Installed (estimated time 10 to 20 minutes)

If you are using OS X 10.5 or 10.6 do the following:
  • Download the latest stable OS X installer .dmg file from http://plone.org/products/plone/releases/4.0.5
  • Start the GUI installer
  • At 'Installation Type' select 'Other' and browse to 'Desktop' and create a folder called 'dexterity'. Ensure that 'dexterity' is selected and click 'Continue'.
    skitched-132
If you are using OS X 10.4 do the following:
  • Cut and paste the following into your terminal:
curl -O http://launchpadlibrarian.net/68926027/Plone-4.0.5-UnifiedInstaller.tgz
tar xvfz Plone-4.0.5-UnifiedInstaller.tgz
cd Plone-4.0.5-UnifiedInstaller
./install.sh standalone --target=$HOME/Desktop/dexterity
cd $HOME/Desktop/dexterity

(On an old single core Macbook Pro the above command took about 20 minutes to execute, which includes compiling a complete copy of python 2.6.)

Make a note of your admin password. If you need to find it again it is located at Desktop → dexterity→ zinstance→ adminPassword.txt or you can paste this in your terminal:
open $HOME/Desktop/dexterity/zinstance/adminPassword.txt
Step 2 - Add plone.app.dexterity to your buildout configuration (estimated time 5 minutes)
Now with your favourite editor navigate to the Desktop/dexterity/zinstance folder and open the buildout.cfg file with VIM your favourite text editor.

cutting and pasting this into your terminal should do the trick

open $HOME/Desktop/dexterity/zinstance/buildout.cfg

This requires adding two lines, one in the the 'extends' section and the other in the 'eggs' section.

extends =
http://good-py.appspot.com/release/dexterity/1.0-next?plone=4.0.5

eggs =
Plone
PIL==1.1.6
plone.app.dexterity

Then run the buildout command (you can cut and paste the following):

$HOME/Desktop/dexterity/zinstance/bin/buildout -n

note: the -n means 'look for newest packages'. It is definitely needed the first time to ensure that you get up to date packages.

Step 3. - Kick the tyres, ensure everything is working.
Now that everything is installed let's see if it works.
Start your instance by running the following command (you can cut and paste it into your terminal):

$HOME/Desktop/dexterity/zinstance/bin/instance fg

You should see output similar to this:


Now visit http://localhost:8080 with your web browser, you'll see something like this:

Click 'Create a new Plone site' and accept the defaults.
Then go to 'admin' → 'Site Setup' → 'Add-ons', check 'Dexterity content types' and click 'Activate'.


Now go back to "Site Setup", select "Dexterity Content Types" and start tinkering with it.




Troubleshooting
The most common issues are related to either not having XCode installed on your Mac or being on a network which relies on a proxy. If you need to work with a proxy a quick fix is to export your proxy settings just before initiating the download etc.. Like so:

export http_proxy=http://theproxy:theport
e.g.

export http_proxy=http://192.168.0.1:8080

Thursday, September 2, 2010

Plone 4 makes upgrades fast and easy

You probably know that Plone 4 is really fast. Here's a screencast of us upgrading our site from Plone 4.0rc1 to Plone 4.0.












As you see, not only is it very responsive, it's also pretty easy. I have done a few, less trivial upgrades from Plone 3 to Plone 4, hopefully I'll remember to do a screencast about that in the future.

Friday, November 20, 2009

Setting User Passwords - still counter intuitive in Plone 4

This discussion revolves around the question - How can I as an administrator set user passwords?
Let me start by saying, I am an active user of Plone and as far as usability (for administrators and content editors) goes, there are few CMS systems that I've worked with that can hold a candle to Plone. This observation is related to a small issue that I would love to see "fixed".


Before the Rant
Plone 4 is soooo much faster than Plone 3 and I'm loving some of the new usability/convenience features, like the "Image Handling" control panel for managing thumbnail sizes and the newly added ability to specify the group of a newly added user (noted in a screenshot below).
http://img.skitch.com/20091120-1ip2hpdmjh65cnjn65xryp7i4f.jpg
Scenario - Managing Users
When adding a new user, it is not unusual to want to set a user password.
http://img.skitch.com/20091120-83h3gpbb5jqy1dug3y2qnxiss6.jpg

By default, clicking "Site Setup" > "User and Groups" > "Add New User" will present a screen where you can't set a password.
http://img.skitch.com/20091120-jpx88f17ye6wgidb7pyuwerst3.jpg


The solution is to go to "Site Setup" > "Security" and check the "Let users select their own passwords" box.
http://img.skitch.com/20091120-rnrbyrbd1dkhhp5df8af53h57b.jpg

Now when I go back to "User and Groups" > "Add New User", I can now set a password.
http://img.skitch.com/20091120-q5cqwx3xe85wmk93q6jjwd9bwc.jpg
That's just weird!

Possible solution

I think there should be a new option under "Users and Groups". Something like a check box that says "Admin can set passwords".
http://img.skitch.com/20091120-cejtc3u6qu8drp5anuduky8e3f.jpg

In the overall scheme of things this is a tiny issue, but it's worth mentioning and worth fixing.

Python Imaging Library (PIL) with Plone 4 on OS X

The Python Imaging Library (PIL) was not working for me with the Python 2.6 packages that I installed on OS X Leopard.

I resisted for a while, but in the end the solution to my PIL problems on OS X was to compile Python 2.6.

I'm assuming that the following are already installed
  • XCode should be installed
  • Subversion (I use fink to get and install subversion)
I downloaded Python 2.6 from the python.org website

http://python.org/ftp/python/2.6.4/Python-2.6.4.tar.bz2

Then I unpacked and compiled:

tar xvfj Python-2.6.4.tar.bz2
cd Python-2.6.4
./configure && make
sudo make install

Using this version of python (which gets installed to /usr/local/bin) I was able to bootstrap the Plone 4 and compile PIL:

svn co http://svn.plone.org/svn/plone/buildouts/plone-coredev/branches/4.0 plone4
cd plone4
PYTHON=/usr/local/bin/python
$PYTHON bootstrap.py
bin/buildout -c pil.cfg

Thursday, October 15, 2009

Installing Plone 4 on Solaris

Plone 4 is still under development, but I've heard enough to get me curious. This is how I got it working. I ended up installing it on OpenSolaris, should work just as well on Linux. I had issues with MacPython on OS X.
update: I was able to get it to successfully install on OS X Leopard by "downgrading" to macpython 2.6.2. Will need to try the same on Linux.

Important notes:

  • Use Python 2.6 less than Python 2.6.3 (so 2.6.2 and 2.6.1 should work) (thanks to esteele for the tip)
  • Make sure all the supporting python 2.6 packages are installed
    On Solaris this includes SUNWPython26 and SUNWPython26-setuptools (you may possibly also need SUNWPython26-extra)
http://img.skitch.com/20091015-n1n69ucuiyhwjuast6nyaewq5d.jpg

Get PIL installed
Following a tip from speedbreeze. As the root user run the following command
:
easy_install-2.6 -i http://dist.serverzen.com/pypi/simple PILwoTK

Checkout the source, bootstrap and build
svn co http://svn.plone.org/svn/plone/buildouts/plone-coredev/branches/4.0/ plone4
cd plone4
python2.6 bootstrap.py
bin/buildout

I was then able to launch Plone 4:
bin/instance fg
http://img.skitch.com/20091015-fp4b6rk7hn7jk5ci99picgyfq3.jpg


Sign up for my upcoming Plone 5 Book & Video tutorials

plone 5 for newbies book and videos