Spring into Pylons
Opera Software ASA
Jonathan Share
Opera Logo

Spring into Pylons

The widgets.opera.com story

Speaker Info

Introduction

Project Background

Architecture

Architecture - Spring MVC

Diagram of Spring MVC Architecture

Architecture - Pylons Demos

Diagram of Pylons Examples Architecture
def save(self, title):
    page_q = Session.query(Page)
    page = page_q.filter_by(title=title).first()
    if not page:
        page = model.Page()
    page.title = title
    page.content = request.POST.get('content','')
    c.title = page.title
    c.content = page.get_wiki_content()
    c.message = 'Successfully saved'
    Session.save_or_update(page)
    Session.commit()
    return render('/page.mako')

Architecture - Final

Diagram of Chosen Architecture
class BugController(BaseController):
    def new_action(self, id, version):
	bug = Bug()
	# Populate bug instance from FormEncode self.form_result

	g.bugs_service.create_bug(bug)

	# Redirect so the bug report can be viewed
	return h.redirect_to('bug_detail_page', id = bug.id)

Tip - Cache Decorator

class WidgetsService(object):
    """
    The widgets service class is the main entry point for interacting with
    the store of available widgets.

    """

    @cache(timeout=3600)
    def find_categories_with_widgets(self, profile_id, browser_id):
        """
        Gives the list of categories with an extra set attribute 'item_count'
        which holds the number of widgets for the given profile and browser,
        and only categories with item_count greater than 0 are returned.

        """

Tip - Cache Decorator

def cache(timeout=None, exclude_args=None, exclude_kwargs=None):
    """
    General cache decorator that will cache the result of any function/method
    using the module, function name, and call parameters as key. Everything
    that is not None is cached.

    """

Experiences

Problem - Sharing Controller Code

Problem - Translation

Problem - Genshi/Formencode

Problem - Python 2.5 on Debian Etch

OK - SQLAlchemy

Good - Modular Architecture

Good - Performance

Good - Performance

Graph of page hits for July

Summary/Feedback

We're Hiring!

Sverre Johansen

Job details at:
http://opera.com/jobs/

Slides will be available at:
http://my.opera.com/webapplications/