Sunday, February 28, 2010

A Beginner's First Look at Pinax

Before my laborious morning commute to Manhattan the other day, I decided that I would download a copious amount of .pdfs, documentation, and other files in order to learn about python and maybe try out some new python technology. This is where Pinax comes in.

Pinax is a technology based on Django, which in turn is a technology based on Python. Of course Python is a dynamic programming language that is easy to use and especially easy to read. Django is similar to Ruby on Rails, in the fact that it is used to make an easy to use MVC architecture to your web applications. On top of this architecture is Pinax, which takes all of the projects you might find yourself writing over and over again, and throws it into a single command that your run and like magic you're up and running. One of the neatest of these prebuilt projects is the social website project, which basically builds something similar to facebook in a matter of seconds. It's so easy to use it's mind blowing.


But what if I want to customize it?

This is where I had some trouble. And hopefully, this post will help you avoid some of the things that aren't so obvious to a newbie.

I first created a basic project following the documentation provided on pinaxproject.com. But where do I go from here? There are docs on how to customize tabs, but that's it.

The first thing I wanted to do obviously is change the styles. I did some poking around on the internets and some readme file, to find out that you need to create a folder in

pinaxenvironment_path/lib/python2.6/site-packages/pinax/templates/

In this new folder you make whatever changes to templates you want, then whene you're done you have to change your 'pinax_theme' setting in your settings.py to the foldername that you created. By default it is 'default'.

Doing this wasn't really the first thing I thought of, as a newbie.

Next, I wanted to add some of my own application to my default pinax project. I did what I would normally do in Django, create the new app inside the project folder, write my models, views, templates, etc, add to my settings under installed apps. Everything was going great except that my new application couldn't see any of the media from my pinax app, nor could it remember whether or not I was logged in! Thankfully, the people at #pinax on FreeNode were very helpful, and James Tauber answered my issue, which was that I needed to use RequestContext for my views.

All In all, I've only had those two problems so far with Pinax. I sometimes wish there were more documentation on their site. I still have questions.

How can I add and remove specific apps from pinax? What if I wanted just the blog application? I've tried to add and remove applications, but some are dependent on one another and at the time of me downloading the docs, there were no and may still not be any good documentation on how to do this.

I think something like a tutorial of an example site that can be made using pinax would be great. The preset sites are awesome, and they are very useful, but I think that a tutorial outlining how to make tweaks to your piinax site, subtracting certain features or adding features from your own django creations or from other pinax projects would be very useful. I have a very vague idea of what it's like to develop 'in' pinax, and I'd like to see a more concrete example to make sure that I'm going about it in the right manner.

All in all, Pinax is a really exciting technology and I will definitely be using it extensively for any future clients. It's powerful, and the default projects felt really stable, and although changing the theme wasn't initially apparent to me, it was easy to do that, too.

If you're a newbie to python web development and you're curious about these new technologies, then I hope this helped you out.

Also, if you're interested in what pinax can do, check out their website! Or check out cloud27, a project made with Pinax which is really neat!

Happy hacking!

-Sean

Thursday, February 11, 2010

Vim macro saves the day!!

So I had to work on a php script at work. Urg, php isn't exactly my language of choice, but I decided to make the best of it and at least try to have some fun, which I did, while learning something in the process. Here's the scoop:

I had to take something like this:
$output.="blah blah blah blah blah";
and turn it into something like this:
$output.="blah blah blah blah blah\n";
Unfortunately for me, there was a TON of lines like this.
After attending a great talk at nycpython by Justin Lilly on editor efficiency, I decided to try out a 'vim macro' for the first time.

Here's how I solved this problem:
  1. type 'qq' to start recording my macro
  2. type '$' to get to the end of the line
  3. hit 'h' twice to move the cursor left twice
  4. hit 'i' to go into insert mode
  5. type '\n' to put in my line break
  6. hit the esc key to get out of insert mode
  7. hit 'j' to move down to the next line
  8. hit 'q' to stop recording the macro
  9. type '20@q' to execute the macro 20 times
So this means that in order to create the macro, the syntax is:
qq commands q
..and then to execute it multiple times:
x@q
...where 'x' is the number of times you want to execute it.

I'm sure that there are many ways to do this, being that vim is such a powerful editing tool.
Anyways, the macro is definitely a tool I see myself using in the future, as it cut down the monotony and time needed to accomplish this annoying task.

Happy coding,
Sean

Wednesday, February 10, 2010

Lots of new stuff!

Lots of new stuff going on!

I'm an intern right now at we-care.com, doing web/application development, scripting, analytics, debugging, testing, and anything else geek related. It's a blast! I get to learn and use a lot of neat tools like sed and awk

Also, I joined a couple of cool meet-up groups like Django nyc and python nyc, each of which has a lot of really smart people involved, lot of great ideas coming out of those groups. Lot's to learn from them!!

I was able to meet Steve Holden of the Python Software Foundation, as well as Jakob Kaplan Moss, one of the founders of the Django open source project, got to hear some interesting stories and have a few beers, thanks to our sponsor, HUGE inc.

Pycon is coming up, unfortunately I can't go, being a student requires that you be too poor to do anything like that, haha. Fortunately, there's going to be a lot of coverage from people at django nyc and python nyc, so there's still a lot to look forward to.

And to top it all off, I made it to the very last level for the first time in nethack, I got all the way to the Astral plane and got demolished. It was my first time getting even remotely far in that game, which was pretty cool, although it kinda sucked that I didn't ascend. Oh well, much to learn from that I guess.

Well, back to work, hopefully I'll have a cool project to work on soon that I can make a couple posts about. I've got a few ideas floating around but I need to find a bit of time to get them rolling.