Archive for October, 2008

Why PacktPub?

Over the last year I have read and reviewed a lot of books by Packt Publishing, and I wanted to share one of the reasons (aside from the awesome books) why I have chosen to work with Packt Publishing.

From PacktPub.com

Packt Open Source Project Royalty Scheme

Packt believes in Open Source. When we sell a book written on an Open Source project, we pay a royalty directly to that project. As a result of purchasing one of our Open Source books, Packt will have given some of the money received to the Open Source project.

In the long term, we see ourselves and yourselves, as customers and readers of our books, as part of the Open Source ecosystem, providing sustainable revenue for the projects we publish on. Our aim at Packt is to establish publishing royalties as an essential part of the service and support business model that sustains Open Source.

It’s this kind of commitment from a publisher that really separates the wheat form the chaff.  I feel good when I read a book that is written by Packt because I know that I am, at least in some part, giving back to a community that has given so much to us.

Book Review: Expert Python Programming (PacktPub)

Expert Python Programming by Tarek Ziade (PacktPub.com)

Expert Python Programming by Tarek Ziade (PacktPub.com)

Expert Python Programming was not what I was expecting to get from a book about Python. I am not a savvy python programmer yet, and in my quest to become one I picked this book up to read. It certainly is not for beginners, and I mean that. If you are not comfortable you may wish to skip it, if you are daring and have the basics of programming down then you can slip this one into your collection.

Tarek Ziade presents, for the most part, best practices and design patterns. Chapters 8 through 14 really are just that, explaining how to be a really great python programmer. From Test-driven design, to Optimization he covers all the bases and if the suggestions and steps are followed even the worst of programmers (no matter the language) could become an expert programmer.

Chapters 2 and 3 literally blew my mind, I mean that! The concepts aren’t earth shattering, but they are really good and indepth. I am glad I had the chance to review the book and read those chapters as they gave me some great insight to the language of Python. 

Overall this book has really opened my eyes to the powers of Python and even more how to be a better programmer in general. Thanks Tarek!

You can pick up this novel of awesome at Amazon.com, or check out more details on the book at PacktPub.com.

Josso & PHP

I recently had the pleasure, if you would like to call it that, to implement JOSSO with PHP at my work. I quickly learned a few things about the process of setting up Josso with PHP, that aren’t well documented, and as such I am going to share my findings.

Downloading
Let’s start with downloading the PHP library for Josso. Most people will head straight to the SF.net repository for Josso and look for the PHP link. Well, let me save you the headache, it ain’t there. The PHP library is stored inside of the josso main package (currently josso-1.7.zip as of this writing). The main package by-the-way is 80+ MB. You are looking for roughly 30Kb of files inside that zip.

Inside the zip you will find tons of files, and folders . Let me guide you to where the PHP files are: (after unzipping)

\josso-1.7\josso\core\src\plugins\php\php

No, the double php is not a typo. Inside of that directory you will find three class files, a config file, a couple of login/logout views, the security check, and the josso file. Be forewarned there is also a nusoap directory, and this thing will cause some headache if you are not prepared.

Installation
Unless you have full control of your server that you are installing the JOSSO + PHP interface on, you will not have access to add Josso to the php.ini file to make is autoload on every single page. For this I really suggest using a MVC with Front Controller setup. This allows you to force the user through a single point to access any part of your site, and thus eliminates the need to make Josso autoload for every single php file on your site.

SOAP
Finally I want to talk about Josso’s implementation of SOAP. On their PHP site they write:

In case of using PHP5 be sure of disabling the native SOAP support in order to avoid conflicts with the SOAP API used by JOSSO.

That is 100% completely not needed. Here is why. The SOAP class they do use doesn’t touch the SOAP class from PHP, and as such it can simply have all references changed. I simply loaded all the files from Josso into Eclipse and did a find and replace on soapclient (the actual class that conflicts) and renamed it to josso_soapclient. There were only a handful of places to change this, maybe 10. Once they were renamed the Josso + PHP experience was quite simple.

Example Scripts
Lastly I want to quickly mention that when you load the sample scripts provided by Josso, you will get errors. Apparently some of the methods have changed since they wrote the Josso examples. I have submitted my changes to the Josso project, and I hope that they will be included as they only make sense. So if you get errors, just go into the code and look to see if 1) the method exists anywhere, and 2) find a similar method and call it.

Conclusion
I don’t want to sound as though I am bagging on Josso at all, instead I am just letting people know the problems I had, and how I fixed them. The rest of the setup was really quite simple. For Single Sign-on, Josso is great.

Update
So another small annoyance I found while using Josso was that when you send a bad login to Josso, Josso will hijack your user experience. I was passing the “josso_back_to” string, and I couldn’t think why it wouldn’t send the user back. It turns out that Josso only uses the “josso_back_to” string when there is a valid login, and a second parameter of “josso_on_error” is required for bad logins (or errors).