<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wyatt Baldwin &#187; pylons</title>
	<atom:link href="http://wyattbaldwin.com/tag/pylons/feed/" rel="self" type="application/rss+xml" />
	<link>http://wyattbaldwin.com</link>
	<description></description>
	<lastBuildDate>Tue, 20 Jul 2010 17:43:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ruby on Rails&#8230; Revisited</title>
		<link>http://wyattbaldwin.com/2008/04/04/ruby-on-rails-revisited/</link>
		<comments>http://wyattbaldwin.com/2008/04/04/ruby-on-rails-revisited/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 03:54:56 +0000</pubDate>
		<dc:creator>Wyatt</dc:creator>
				<category><![CDATA[dev]]></category>
		<category><![CDATA[planet python]]></category>
		<category><![CDATA[comparisons]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[grok]]></category>
		<category><![CDATA[pylons]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web frameworks]]></category>
		<category><![CDATA[zope 3]]></category>

		<guid isPermaLink="false">http://wyattbaldwin.com/?p=130</guid>
		<description><![CDATA[Updated with links and a couple typo corrections. I&#8217;ve been working on a fairly big Web site project lately. My partner and I initially decided to use Django to build the site, mainly because I&#8217;m a Python &#8220;expert&#8221; and Django &#8230; <a href="http://wyattbaldwin.com/2008/04/04/ruby-on-rails-revisited/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>Updated with links and a couple typo corrections.</em></p>
<p>I&#8217;ve been working on a fairly big Web site project lately. My partner and I initially decided to use <a title="Django Python Web Framework" href="http://www.djangoproject.com/">Django</a> to build the site, mainly because I&#8217;m a <a title="Python programming language" href="http://python.org/">Python</a> &#8220;expert&#8221; and Django is (apparently) the #1 Python Web framework. We were also lured by the easy admin interface.</p>
<p>After trying to use Django and not really enjoying it, I tried switching to <a title="Pylons Python Web Framework" href="http://pylonshq.com/">Pylons</a> because I&#8217;ve had a good amount of experience with it in the building of <a title="byCycle bicycle trip planner / route finder" href="http://bycycle.org/">byCycle.org</a>. It&#8217;s gone through two fairly major releases since then, and so have a bunch of the libraries that tend to get used with it, like <a title="SQLAlchemy Python database library" href="http://sqlalchemy.org/">SQLAlchemy</a>, <a title="Elixir Python Active Record library" href="http://elixir.ematia.de/trac/wiki">Elixir</a>, etc.</p>
<p>I was having a hard time with the Pylons docs, and so I ended screwing around with <a title="Grok Python Web framework" href="http://grok.zope.org/">Grok</a> (which actually looks fairly interesting) and even took a look at the <a title="Zope 3 Python Web framework" href="http://wiki.zope.org/zope3/Zope3Wiki">Zope 3</a> site. I&#8217;m sure Zope is really awesome or whatever, but it might as well suck. Every time I look at that site, I&#8217;m just like &#8220;WTF! This shit has been around for like five years!&#8221; Anyway, I might just not be smart enough for Zope.</p>
<p>This led us back toward <a title="Ruby on Rails Web framework" href="http://rubyonrails.org/">Rails</a> (even if <a title="Rails is a ghetto?" href="http://www.zedshaw.com/rants/rails_is_a_ghetto.html">it is a ghetto</a>). I used Rails a bit last year but never did anything too serious with it. Diving into it today was quite a pleasure. There are issues to be sure, but overall I&#8217;m enjoying it <em>by far</em> over any of the other options we had tried. I&#8217;m also enjoying learning/relearning <a title="Ruby programming language" href="http://www.ruby-lang.org/">Ruby</a>.</p>
<p>If Pylons had good docs, we&#8217;d probably be using that.</p>
<p>So, I don&#8217;t know if this is a particularly useful post, since I didn&#8217;t get into much in the way of reasons (what, i have back this up?!). This subject&#8217;s been hashed and rehashed, but I just wanted (<em>needed</em>) to make a qualitative statement about my/our experience, which, of course, is purely personal.</p>
]]></content:encoded>
			<wfw:commentRss>http://wyattbaldwin.com/2008/04/04/ruby-on-rails-revisited/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Restler, a RESTful Base Controller for Pylons</title>
		<link>http://wyattbaldwin.com/2007/04/17/restler-a-restful-base-controller-for-pylons/</link>
		<comments>http://wyattbaldwin.com/2007/04/17/restler-a-restful-base-controller-for-pylons/#comments</comments>
		<pubDate>Tue, 17 Apr 2007 11:38:14 +0000</pubDate>
		<dc:creator>Wyatt</dc:creator>
				<category><![CDATA[planet python]]></category>
		<category><![CDATA[pylons]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://wyattbaldwin.com/2007/04/17/restler-a-restful-base-controller-for-pylons/</guid>
		<description><![CDATA[“Restler is a base controller for Pylons projects that provides a set of default RESTful actions that can be overridden as needed. It also handles database connectivity as long as a few simple rules are followed. It adds a bit &#8230; <a href="http://wyattbaldwin.com/2007/04/17/restler-a-restful-base-controller-for-pylons/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>“Restler is a base controller for <a href="http://pylonshq.com/">Pylons</a> projects that provides a set of default RESTful actions that can be overridden as needed. It also handles database connectivity as long as a few simple rules are followed.</p>
<p>It adds a bit of ‘convention-over-configuration’ to Pylons and takes some inspiration from Rails’ scaffold_resource generator…”</p>
<p>Restler’s aim is twofold: 1) make it easier to get started with Pylons and 2) encourage a RESTful project architecture.</p>
<p>It attempts to remove some of the pain of database setup in a Pylons project by providing a default configuration. All users need to do is specify their connection settings with one line in a config file.</p>
<p>The project is hosted at Google Code. There is a “Quick Start” guide there on the <a href="http://code.google.com/p/restler/">project home page</a> (which also serves as a mini introduction to getting started with Pylons).</p>
<p>All feedback is welcome; please feel free to make use of the <a href="http://code.google.com/p/restler/issues/list">issue tracker</a>.</p>
<p>—</p>
<p>PS If anyone happened to come across Restler on the Cheeseshop previously, some of the wonkiness has been removed (e.g., use of execfile to “include” restler) and most of the actions have been filled out such that they actually do (something closer to) the right thing.</p>
<p>PPS Sorry about the comment spam earlier on Planet Python. I’m not really sure why comments are coming through, and I don’t see any settings in Mephisto that would allow me to change that. I disabled comments for <a href="http://blog.wyattbaldwin.com/2007/3/22/creating-a-google-maps-toscawidget">the offending  post</a> and emailed the Planet Python moderator to see if there’s anything that can be changed on that end.</p>
]]></content:encoded>
			<wfw:commentRss>http://wyattbaldwin.com/2007/04/17/restler-a-restful-base-controller-for-pylons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a (Google Maps) ToscaWidget</title>
		<link>http://wyattbaldwin.com/2007/03/21/creating-a-google-maps-toscawidget/</link>
		<comments>http://wyattbaldwin.com/2007/03/21/creating-a-google-maps-toscawidget/#comments</comments>
		<pubDate>Thu, 22 Mar 2007 06:13:46 +0000</pubDate>
		<dc:creator>Wyatt</dc:creator>
				<category><![CDATA[planet python]]></category>
		<category><![CDATA[pylons]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[toscawidgets]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://wyattbaldwin.com/2007/03/21/creating-a-google-maps-toscawidget/</guid>
		<description><![CDATA[[Updated 28 Mar 2007 after tweaking twMaps according to Alberto’s comments.] I’ve been watching ToscaWidgets (TW) for a while now and keep thinking that widgets could be very useful. I’ve been perusing the TW site and the new TW mailing &#8230; <a href="http://wyattbaldwin.com/2007/03/21/creating-a-google-maps-toscawidget/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>[Updated 28 Mar 2007 after tweaking twMaps according to Alberto’s comments.]</em></p>
<p>I’ve been watching <a href="http://toscawidgets.com/">ToscaWidgets</a> (TW) for a while now and keep thinking that widgets could be very useful. I’ve been perusing <a href="http://toscawidgets.com/">the TW site</a> and the <a href="http://groups.google.com/group/toscawidgets-discuss">new TW mailing list</a>, and there doesn’t seem to be much documentation on how to create new widgets.</p>
<p>Today, I got the idea to create a Google Maps widget. It started with someone asking in the #<a href="http://pylonshq.com/">pylons</a> IRC channel about getting access to a domain-specific <a href="http://www.google.com/apis/maps/">Google Maps <span class="caps">API</span> key</a> from the configuration settings during a request.</p>
<p>In the <a href="http://tripplanner.bycycle.org/">byCycle trip planner</a>, our <span class="caps">API</span> keys are buried in <a href="http://trac.bycycle.org/browser/apps/web/tripplanner/branches/dojo/tripplanner/public/javascripts/gmap.js">a JavaScript file</a>, but the config file would be a much better place for them. But then there’s the question of how to stuff the right <span class="caps">API</span> key into the JavaScript at the right point. Widgets seemed like they might be the answer, and since a map widget is something that could be useful in the <a href="http://tripplanner.bycycle.org/">trip planner</a>, I decided to “dive in.”</p>
<p>By looking through <a href="http://toscawidgets.org/toscawidgets.html">the examples in the TW documentation</a>, <a href="http://trac.turbogears.org/browser/projects/ToscaWidgets/trunk/">the TW source</a>, <a href="http://trac.turbogears.org/browser/projects/ToscaWidgetsForms/trunk">the twForms source</a>, and <a href="http://docs.pythonweb.org/download/attachments/3211267/ToscaWidgetsPyCon.pdf?version=1">this <span class="caps">PDF</span> of a presentation by Kevin Dangoor</a>, I was able to get something reasonable working within a few hours. It’s even easy_install-able (<code>easy_install twMaps</code>).</p>
<p>I also created a simple Pylons project to test the widget. <a href="http://docs.pythonweb.org/display/pylonscookbook/An+Alternative+ToscaWidgets+Setup+with+Mako">This entry</a> on the new <a href="http://docs.pythonweb.org/">Python Web Documentation Project</a> site was very helpful for showing how to integrate ToscaWidgets into a Pylons application (I assume there’ll soon be a magic incantation you can use instead of copying a bunch of stuff into your middleware settings).</p>
<p>What I’m going to focus on in this post is <em>creating</em> a new widget and packaging it up for use by others, using a recipe-style approach with commentary at each step. In a future post, I’ll show how to use the twMaps Google Maps widget in a Pylons project. For now, you can browse a sample Pylons app <a href="http://trac.bycycle.org/browser/spinoffs/twMaps/twMapsSampleAppPylons?rev=1018">here</a>.</p>
<h3>Install ToscaWidgets</h3>
<pre>easy_install -U ToscaWidgets</pre>
<h3>Create a Package Layout</h3>
<p>ToscaWidgets includes a paster template for creating a package layout:</p>
<pre><code>paster create --template=toscawidgets</code></pre>
<p>This will prompt for a bunch of info, then create a directory structure similar to this:</p>
<pre>- twMaps
    - twMaps.egg-info
    - tests
    - toscawidgets
        - widgets
            - maps
                - release.py
                - samples.py
                - widgets.py
                - __init__.py
        - __init__.py
    - setup.cfg
    - setup.py</pre>
<p>Under the ‘maps’ directory, I added this:</p>
<pre>                - static
                    - gmap
                        - gmap.css
                        - gmap.js
                    - templates
                        (Empty for now)
                    - gmap.py  (GMap widget class will go here)</pre>
<p>This layout allows for multiple related widgets in a package. You could put multiple widgets in ‘widgets.py’ and import them all into &#8216;maps.<em>init</em>.py&#8217;, but I prefer to put each widget into a separate module, then import each one into &#8216;maps.<em>init</em>.py&#8217;.</p>
<p>There are only a few files you need to create for each widget. It’s possible to write your <span class="caps">HTML</span> template, <span class="caps">CSS</span>, and Javascript inline in the widget module, but usually that’s a bad idea. In my case, the <span class="caps">HTML</span> template was so simple, that I wrote it inline anyway (which is why the templates directory is empty).</p>
<h3>Create Your Widget</h3>
<p>Conceptually, creating a widget is quite simple. You create your static resources (stylesheets and javascripts) and template and tie everything together in a widget class. In your Web app, you just import your widget, pass it some parameters, and tell it to display itself. (You have to add a few lines to your templates also—see below.)</p>
<h4>The javascript</h4>
<pre>/* gmap.js */

twGMap = (function () {
  var api_url = 'http://maps.google.com/maps?file=api&amp;v=2&amp;key=';

  function $(id) {
    return document.getElementById(id);
  }

  return {
    load_api: function (api_key) {
      document.write('<script src="http://wyattbaldwin.com/wp-admin/%5C%27%20+%20api_url%20+%20api_key%20+%3Cbr%20/%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5C%27" type="text/javascript"><!--mce:0--></script>');
    },

    /**
     * ``opts`` is an Object that may contain the following keys:
     *     ``center_y``
     *     ``center_x``
     *     ``zoom``
     */
    create_map: function(container_id, opts) {
      // We need ``_create_map`` to close over ``container_id`` and ``opts``
      var _create_map = function () {
        if (typeof(GMap2) == 'undefined') {
          setTimeout(_create_map, 1000);
          return;
        }
        var container = $(container_id);
        var map = new GMap2(container);
        center_y = opts.center_y || 0;
        center_x = opts.center_x || 0;
        zoom = opts.zoom || 7;
        map.setCenter(new GLatLng(center_y, center_x), zoom);
        // TODO: add opts for everything below
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.addControl(new GScaleControl());
        map.addControl(new GOverviewMapControl());
        map.enableContinuousZoom();
        new GKeyboardHandler(map);
        this.map = map;
      }
      _create_map();
    }
  }
})();</pre>
<p>There’s nothing particularly special about this—it’s just JavaScript.</p>
<p>(Aside: The only thing that may be interesting is the style, if you haven’t seen it before. The anonymous function that everything is wrapped in creates a private namespace. We can declare functions and vars in there and they’re not accessible from the outside. We return an anonymous literal object that exposes twGMap’s public interface. The private vars are accessible within this object.)</p>
<h4>The stylesheet</h4>
<pre>/* gmap.css */

#twgmap {
    width: 400px;
    height: 400px;
}</pre>
<p>Again, nothing interesting; just default dimensions to make sure the map will show up. A user could include a different stylesheet that overrides this.</p>
<p>We could probably also parameterize the dimension settings, send them to the &#8220;create_map&#8220; JavaScript function, and set the map container dimensions using <span class="caps">DOM</span> methods (a good idea actually, now that I think of it). It would also be cool if it was possible to create <span class="caps">CSS</span> templates that can be filled in similarly to <span class="caps">HTML</span> templates. (It’s likely that this already possible and I just don’t know how to do it.)</p>
<h4>The <span class="caps">HTML</span> template</h4>
<p>Normally, you’d probably write your <span class="caps">HTML</span> template in a separate file under the templates directory. As you can see in the &#8220;GMap&#8220; class below, though, the template for the the Google Maps widget is very simple, so I just wrote it inline.</p>
<p>To point to a template in a separate file, use Buffet syntax, which looks something like this:</p>
<pre>template = 'template-package:path.to.template'</pre>
<h4>The widget class</h4>
<p>Here’s where things start to get interesting. The <span class="caps">HTML</span> template, JS and <span class="caps">CSS</span> above are just standard stuff, and we could use them by copying them into our project and using script and link tags to include the JS and <span class="caps">CSS</span> in the template.</p>
<p>In other words, we don’t <em>need</em> to create a widget, but there are some compelling reasons for why we might want to.</p>
<p>For one thing, we normally have separate directories for different types of files (css, js, etc). We don’t have to do this—we could create a widgets directory with a layout similar to the one above. This would get us part way there in that it would at least be a little easier to detach a particular widget from a project and use it somewhere else.</p>
<p>Using Widgets, though, allows complete separation; the files don’t need to be copied into your project at all. You just import the widget and it sets things up so your framework knows how to access the widget’s resources. This makes it really easy for you to reuse your widgets and share them. In turn, it makes it easy for you to use other widgets (the twForms package has a bunch, for example).</p>
<p>Another thing that’s nice with Widgets is that we don’t have to manually include widget templates or script and link tags ourselves. The widget system knows how to do that for us, so that all that’s required to display a widget in a page is telling it to display itself in a particular place in the page.</p>
<p>So, there are some reasons to use widgets; now, let’s look at the code.</p>
<pre># gmap.py

from toscawidgets.api import Widget, CSSLink, JSLink, js_function

__all__ = ['GMap']

twgmap_css = CSSLink(modname=__name__, filename='static/gmap/gmap.css',
                     media='screen')
twgmap_js = JSLink(modname=__name__, filename='static/gmap/gmap.js')

class GMap(Widget):
    params = ['css_class', 'map_opts']
    css_class = 'twgmap'
    map_opts = {'api_key': None, 'center_y': 0, 'center_x': 0, 'zoom': 14}
    template = '

'
    css = [twgmap_css]
    javascript = [twgmap_js]
    include_dynamic_js_calls = True

    def __init__(self, id=None, parent=None, children=[], **kw):
        self.map_opts.update(kw.get('map_opts', {}))
        super(GMap, self).__init__(id, parent, children, **kw)

    def update_params(self, d):
        super(GMap, self).update_params(d)
        self.add_call('twGMap.load_api("%s");' % self.map_opts['api_key'])
        create_map = js_function('twGMap.create_map')
        # Use initial map opts as base...
        map_opts = self.map_opts.copy()
        # ...then update with map opts in ``d``
        map_opts.update(d.get('map_opts', {}))
        for k in map_opts:
            try: v = float(map_opts[k])
            except: pass
            else: map_opts[k] = v
        self.add_call(create_map(self.id, map_opts))</pre>
<p>There’s not a whole lot to it in the end.</p>
<p>&#8220;CSSLink&#8220;, in essence, creates a stylesheet link tag. The link is relative to the &#8220;modname&#8220; <em>package</em> so that if &#8220;modname&#8220; is “twmaps.widgets.maps.gmap” and filename is “static/my_widget/my_widget.css”, the full path to the <span class="caps">CSS</span> file will be ”/twmaps.widgets.maps.gmap/static/my_widget/my_widget.css”. &#8220;JSLink&#8220; does the same thing.</p>
<p>Basically, CSSLink and JSLink are just fancy ways to create <span class="caps">CSS</span> &amp; JS tags that can be associated with a widget in Python. Using &#8220;twgmap_css&#8220; from the example above, <code>twgmap_css.display()</code> outputs ’&lt;link rel=”stylesheet” type=”text/css” href=”/twmaps.widgets.maps.gmap/static/gmap/gmap.css” media=”screen” /&gt;’.</p>
<p>Inside the &#8220;GMap&#8220; class:</p>
<p>&#8220;params&#8220; are the params that can be set when creating a widget; they get added to the &#8220;params&#8220; list of any base classes. We can set a default value for a param, as I did with both &#8220;css_class&#8220; and &#8220;map_opts&#8220;. (I think params can be set to be required too.)</p>
<p>The first argument passed to the constructor becomes the &#8220;id&#8220; param. (One issue I had was that I was unable to set a default &#8220;id&#8220; and then override it.)</p>
<p>&#8220;template&#8220; is the <span class="caps">HTML</span> template for the widget. It can either be specified directly as a string or as pointer to an external template file. The names in &#8220;params&#8220; are available in the template (e.g., <code>${css_class}</code>).</p>
<p>&#8220;css&#8220; is a list of <span class="caps">CSS</span> resources; note that it must be a list, even if it just contains one item</p>
<p>&#8220;javascript&#8220; is just like &#8220;css&#8220; (at least in basic usage)</p>
<p>&#8220;include_dynamic_js_calls&#8220; tells the widget to include JavaScript function calls during page load; you specify these functions using &#8220;self.add_call&#8220;. The argument to &#8220;add_call&#8220; is JavaScript code in the form of a string. Those JS calls are added to the bottom of the <span class="caps">HTML</span> body.</p>
<p>In the code above, I used &#8220;js_function&#8220; to generate a Python function that when called, creates a string of JS code. The arguments to that function are converted to <span class="caps">JSON</span>, which become the args to the JS function call.</p>
<p>So there you have it: set up some <span class="caps">CSS</span> and JS links, point to your <span class="caps">HTML</span> template, define parameters for the widget that you can pass through to your template and/or JS, add some callbacks to initialize your JS, and that’s about it.</p>
<p>Example usage:</p>
<pre>&gt;&gt;&gt; from toscawidgets.widgets import maps
&gt;&gt;&gt; opts = {'api_key': 'XYZ', 'center_y': 45, 'center_x': -123}
&gt;&gt;&gt; map_widget = maps.gmap.GMap('twgmap', map_opts=opts)
&gt;&gt;&gt; map_widget.display()
'&lt;div id="twgmap" class="twgmap"&gt;&lt;/div&gt;'</pre>
<h3>Test</h3>
<p>Tests would be a good thing to add, yes. Using ‘paster create’ to generate the package layout creates a tests package to use as a starting point.</p>
<h3>Package It Up</h3>
<p>Packaging is a matter of writing a setup.py file that contains various metadata (name, license, and so forth) and then running a build command. Using the ‘paster create’ command generates a setup.py—it prompts for the metadata and fills in setup.py with that metadata and the necessary commands. It may be necessary to tweak setup.py, but then again, it may not.</p>
<p>Once setup.py is in order, we can run <code>python setup.py bdist_egg</code>. The resulting egg can be found in the dist directory. You could post this somewhere and people could download it and install it using <code>python setup.py install</code>. It’s much cooler though to put the package up on PyPI (AKA cheeseshop). Here’s one way to do that:</p>
<pre>python setup.py register  # follow instructions
python setup.py register bdist_egg upload
python setup.py register sdist upload
easy_install YourPackage</pre>
<h3>Installation/Download</h3>
<h4>Install latest version of twMaps</h4>
<pre>easy_install -U twMaps</pre>
<h4>Check out the code, including a sample Pylons app</h4>
<pre>svn co http://guest:guest@svn.bycycle.org/spinoffs/twMaps</pre>
<h3>Conclusion</h3>
<p>That concludes creating and packaging a ToscaWidget. In an upcoming post, I’ll go through an example of using the GMap widget in a Pylons project.</p>
<p>Please add any corrections, suggestions, etc in the comments. If you have any questions, I’ll try to answer them, but keep in mind that I am just getting started with TW myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://wyattbaldwin.com/2007/03/21/creating-a-google-maps-toscawidget/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails and Opinions on Opinionated Web Frameworks</title>
		<link>http://wyattbaldwin.com/2006/10/15/ruby-on-rails-and-opinions-on-opinionated-web-frameworks/</link>
		<comments>http://wyattbaldwin.com/2006/10/15/ruby-on-rails-and-opinions-on-opinionated-web-frameworks/#comments</comments>
		<pubDate>Sun, 15 Oct 2006 14:16:15 +0000</pubDate>
		<dc:creator>Wyatt</dc:creator>
				<category><![CDATA[dev]]></category>
		<category><![CDATA[pylons]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[web frameworks]]></category>

		<guid isPermaLink="false">http://wyattbaldwin.com/2006/10/16/ruby-on-rails-and-opinions-on-opinionated-web-frameworks/</guid>
		<description><![CDATA[I originally started this over on the byCycle blog [which is currently offline--3/20/08], but it doesn’t really belong there, so I moved it over here on 1/3/2007. It’s not finished, but I think it may contain some useful info, so &#8230; <a href="http://wyattbaldwin.com/2006/10/15/ruby-on-rails-and-opinions-on-opinionated-web-frameworks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>I originally started this over on the <a href="http://bycycle.org/blog">byCycle blog</a> [which is currently offline--3/20/08], but it doesn’t really belong there, so I moved it over here on 1/3/2007. It’s not finished, but I think it may contain some useful info, so here it is…</em></p>
<h3>Introduction</h3>
<p>In this post I’m going to discuss my first real foray into the world of Ruby and Ruby on Rails (AKA Rails). I’m also going to talk about how my initial experience with Ruby and Rails has differed from my recent and ongoing experience with Pylons, a similar-to-Rails Python framework.</p>
<h3>Background</h3>
<p>Recently, mostly by chance, I came across a job posting on craigslist by a local startup looking for a Ruby on Rails developer. I’m not actively looking for a job, but I guess I was “bored” or something and was curious what the jobs landscape in Portland is looking like these days.</p>
<p>A (long) while back when I was looking at CL more regularly, it seemed like all the jobs were Java or <span class="caps">PHP</span> related and required five years of experience (yes, I’m generalizing). Now I’m not gonna say I “hate” Java or <span class="caps">PHP</span>, but the end result is about the same. On the other hand, this job looks very interesting, and I’m even preparing a cover letter and resume for it.</p>
<p>Since getting into Python about two years ago, I’ve heard of Ruby and even tinkered with it some. And since we’re developing a <a href="http://tripplanner.bycycle.org/" title="byCycle Bicycle Trip Planner">Web application</a>, I’ve definitely heard of Ruby on Rails. Several months back, I created a Rails project and poked around in it some (i.e., typed ‘rails project_name’ then ’./script/server’) but didn’t really do anything with it.</p>
<p>There seems to be a little strain between the Python and Ruby communities, especially on the Web framework front, but the consensus seems to be that the two languages are more similar than different. My recent experience has been with Python Web frameworks similar to Rails, especially Pylons.</p>
<p>From past experience learning new languages, and particularly because of their similarities, I don’t think I would have any trouble transitioning from Python/Pylons to Ruby/Rails. Just to make sure, though, I figured I should do at least a small project using Rails. I haven’t done anything with my personal site in a long time and it’s fairly simple, so I decided to give it a Rails makeover.</p>
<h3>Initial Impressions</h3>
<ul>
<li>Ruby: +1</li>
<li>Wacky Interactive tutorial and book: +1 [Why’s]</li>
<li>Rails: +1</li>
<li>Rails support and community: +1</li>
<li>Opinionated frameworks: +1</li>
<li>RadRails Eclipse-based <span class="caps">IDE</span>: +1</li>
<li>Emacs as Rails <span class="caps">IDE</span>: -1</li>
<li><span class="caps">VIM</span> (actually cream) as Rails <span class="caps">IDE</span>: -1</li>
</ul>
<h3>First Steps</h3>
<p>One of the first things I did was to check out the official Ruby site. What I especially liked there was the interactive tutorial, which embeds a Ruby console in a Web page. Even non-programmers would be able to follow this, and I recommend giving it a try. If you’re a seasoned programmer, the tutorial is pretty lightweight, but it does serve as a good introduction to Ruby if you’ve never really done anything with it.</p>
<h3><span class="caps">IDE</span></h3>
<p>I’m using Ubuntu, and I first started working on the project in Emacs. Emacs is a good editor and is what I have historically used for all kinds of files, but I’m finding that it kind of sucks (at least for me) for this type of thing, even after installing all the whiz-bang Ruby/Rails modes and whatnot.</p>
<p>One thing I really like is an easy way to navigate all the project files. I like document tabs and tree views and that sort of thing. I tried various ways of getting those things in Emacs and <span class="caps">VIM</span>, but it just seems clunky, and doesn’t have all the pretty little icons and stuff.</p>
<p>Internet research turned up a few other contenders. A few people seem to be happy with JEdit and claim it can be set up to be very similar to TextMate on Mac <span class="caps">OS X</span>. I wouldn’t know because I haven’t used TextMate extensively and I haven’t installed JEdit yet (and I might not).</p>
<p>I already had Eclipse installed from an earlier attempt at using PyDev. I never used it much because it was too damn slow. Important: This time around I am using Sun’s <span class="caps">JVM</span> [<em>now GPLed, w00t!</em>] instead of the one that comes with Ubuntu, and this makes a huge difference: I’m actually able to use it!</p>
<p>So far, it does seem pretty rad indeed [<em>with the Eclipse RadRails plugin</em>]. One gotcha so far: it requires setting a host, port, and password in database.yml, even if you don’t need this from the command line. Something to do with <span class="caps">ODBC</span> or <span class="caps">JDBC</span> or whatever Eclipse/Java uses to connect to databases.</p>
<h3>Database Issues</h3>
<p><em>I don’t remember what I thought the issues were way back when. It turned out that the FreeBSD 6.1 jail (VPS) I was trying to deploy to had some issue with Postgres and semaphores and ports and other users and some such (yada yada), and Postgres would continuously barf (randomly, sometimes staying up for days, sometimes hours). The hosting company was no help, I couldn’t find much info via The Google, and it just wasn’t worth the trouble at the time, so I gave up and dumped the company.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://wyattbaldwin.com/2006/10/15/ruby-on-rails-and-opinions-on-opinionated-web-frameworks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
