Monday, June 11, 2012

Connection Demo

I spent my development time this week working on a demo implementation of the connection strategy, utilizing existing code in gsoc/views/invite.py and request.py for simplicity's sake. I'm going to spend the next couple of weeks cleaning everything up and, as mentioned in my previous post, consider the option of replacing request.py and invite.py with connection.py. This option is seeming more and more appealing as I move on since (as previously mentioned) it doesn't matter who initiated the connection, only that one exists. There is no distinction between a request and an invitation, so I don't see basis for separating them. I know that there are a lot of things I need to fix before I actually submit everything to the main repo and I've made note of them; the goal of this week was merely to get a working replacement of GSoCRequest with GSoCConnection up and running. I'm using pastebin here and haven't committed anything to a branch of the main repo to save myself revisions while I'm finishing up the demo.

A lot of what I've done is simplify the logic of the two modules to use GSoCConnection rather than GSoCRequest - nothing too elaborate yet. Here's a snippet from request.py, which handles the POST request when a User requests to become a mentor for a particular organization. It generates a GSoCConnection instance between the User and the organization properly and forwards the user onto the view_request page (which I'm going to replace later). I've made changes to the checkAccess() and context() methods to facilitate this change, though the latter isn't done yet. Here's the post snippet from invite.py, again context() is still in progress.

One big hangup I've run into is the dashboard presentation and query of these connections. I tried changing a few columns of the ListConfiguration in the __init__() method of my ConnectionComponent class only to find that the table no longer displayed. That said, I dug into the ListConfiguration class and then rewrote the init method to fit my needs (discovering the Python lambda functions in the process, which are fantastic). However, I'm stumped on the following query in the getListData() method:
q = GSoCConnection.all()
 if self.for_admin:
      q.filter('organization IN', self.data.org_admin_for)
 else:
      q.filter('user =', self.data.user)
No matter what I do I cannot seem to get any Organization or User objects to equate or match in this query, even when I know that there are valid objects meeting the criteria in the datastore. I've used the logging module extensively to try to get to the root of the problem but am at a loss as to what I need to do to fix it. Other than that, this week has been an excellent learning experience and I feel far more comfortable with the view system and the lifecycle of a RequestHandler subclass, which will be useful when building the connection module.

No comments:

Post a Comment