Monday, July 11, 2011

GCI 2011 GCI with New Architecture - W7

Hello all,

This week I started with the Public Task view which first showed all the static fields and then I have created a Form to publish comments for the task and to retrieve the work submissions on that view.In the meanwhile my redirects patch got reviewed and I refactored the GSoC Redirects module but due to my mistake, it broke the existing code, I sincerely apologize for that.I have again written the GCI Redirects module avoiding these mistakes.I then wrote the GCI Timeline Helper class and moved some common code to the core.This got reviewed and will be committing this after the previous patches gets approved.After this I wrote the views to create and edit a GCI Task and have learnt some new things in this process and I sent this one for review too and then as advised by Madhu I moved onto to the task workflow, as the first step I have written a form with a drop down that has the list of actions that are available to the Org Admin, Mentor or Student depending upon the task status.I will be sending this to review now in bit.This week I have spent much more time with my project and in communicating with Madhu which helped me clear many doubts and work better, I feel I have this week's progress is better than the previous ones and I'm happy about it.I will be increasing my time on the project this coming week and will try my best to cover the lag.

GSoC 2011 GUI Overhaul: Push the code and some tasks need to be done

Hi everyone,

Last week I've been working to fix my patches with Daniel. Today I've pushed it into repository. It took a time to convert my commits into chronological patch with Mq. When I sent my patches without Mq, I used the following command to output the patch :

hg export -r started_revision_of_admin_dashboard:tip > patch.diff

Meanwhile the upstream repo changes rapidly with Madhu's changes, so importing the patches that have different tip with my own tip may abort the import. Mq is totally helpful if you're working on many patches while there are rapidly changes in the upstream repo. All you need to do is push your patches into queue and refresh it while receiving feedback from review. And then do hg qfinish to convert the patch into permanent changeset. With the awesomeness of Mq and review/feedback from Daniel and Praveen I just pushed my code a couple hours ago.

The admin dashboard isn't finish yet, there are some functionalities need to be done for PA, such as statistic that Daniel has been working on. I also promised to create MapClusterer to display participant in a single map like the following one:

After finishing the MapClusterer and integrate the statistic module into admin dashboard, I'll working on uploadable org's logo with cropping feature. I've made silly app that prove how Image service from GAE was capable to implement this feature.

Sunday, July 10, 2011

GSoC 2011 Melange Testing Project: CP W7


The task for this week was to correct my previous tests and finish the remaining tests in soc.logic and soc.modules.gsoc.logic. I have corrected my previous tests and submitted them again for the review. I have tested all the logic functions which are used at least once in the code base. I have not tested the soc.logic.allocations, soc.logic.lists and soc.logic.helper.notifications because these are not in my priority list for now as I need more familiarity with the code base to test them correctly and efficiently. I will come back at some time in future to test them.

       I have started attempting to write the view tests. I have never written any view tests earlier and my experience with Django is 0.1, but sometimes we have to learn the hard way. I studied many of the new tests written by Sverre. Testing a view seems to be a complicated task and I did not understand many things which I had to ask Madhu. Just before writing this post, I had a discussion with Madhu and I asked him what 'Context' is, what tests_utils.StuboutHelper is for, what soc.views.helper.access_checker.Mutator is used for and a load of other topics. At the time of writing this blog post, I was testing the soc.views.helper.access_checker. It will consume more time to test because there are more than 1100 lines of code to test. After testing this, I will test the gsoc.views.helper.access_checker module.

      I have the target of completing all the view tests before the final evaluations. It will require a huge amount of effort which I am pouring in. Lets hope for the best. :)

GSoC 2011 Integration with External APIs: Proposal Sync - W7

Approaching to midterm, i partially finished my first deliverable and sent my patches for review. I'm really For now there is one way sync from GDocs to Melange. We are still discussing to allow students "sync back" their proposals to GDocs.

I was struggled with some problems that i want to mention during this blog post. First when using GData libraries on App Engine infrastructure, exporting documents is not directly possible. The reason is that App Engine uses a distrubuted system and this does not allow to write to filesystem. To export anything, GData restricts its API to save output into a file instead of returning exported content. You need little change on gdata library to make it possible:

diff -r 84a930b76e63 -r e65b82d9ad71 app/gdata/docs/
--- a/app/gdata/docs/ Sat Jul 09 03:58:23 2011 +0530
+++ b/app/gdata/docs/ Sun Jul 10 11:27:08 2011 +0300
@@ -106,6 +106,11 @@
         server=server, additional_headers=additional_headers, **kwargs)
     self.ssl = True
+    # Variables used to hack-in Export function to use it
+    # with a file handler instead of file path name.
+    self.file_handler = None
+    self.use_file_handler = False
   def _MakeKindCategory(self, label):
     if label is None:
       return None
@@ -183,10 +188,17 @@
       raise gdata.service.RequestError, {'status': server_response.status,
                                          'reason': server_response.reason,
                                          'body': response_body}
-    f = open(file_path, 'wb')
-    f.write(response_body)
-    f.flush()
-    f.close()
+    def writeResponseToFile(f, close=True):
+      f.write(response_body)
+      f.flush()
+      if close:
+        f.close()
+    if self.use_file_handler:
+        writeResponseToFile(self.file_handler, close=False)
+    else:
+        writeResponseToFile(open(file_path, 'wb'))
   def MoveIntoFolder(self, source_entry, folder_entry):
     """Moves a document into a folder in the Document List Feed.
@@ -346,7 +358,7 @@
     self._DownloadFile(url, file_path)
-  def Export(self, entry_or_id_or_url, file_path, gid=None, extra_params=None):
+  def Export(self, entry_or_id_or_url, file_path, gid=None, extra_params=None, file_handler=None):
     """Downloads a document from the Document List in a different format.
@@ -361,6 +373,13 @@
       RequestError if the service does not respond with success
+    if file_handler:
+      self.file_handler = file_handler
+      self.use_file_handler = True
+    else:
+      self.use_file_handler = False
     ext = None
     match = self.__FILE_EXT_PATTERN.match(file_path)
     if match:

With this you can use a memory file (StringIO) with Export function to write content to file handler directly instead of giving a file name to function for opening.

Second problem was about OAuth authentication page. We were willing to put OAuth page inside a frame in a jQuery dialog instead of a popup window. For strange reasons, page did not show up in the frame. I started an issue to learn the reason behind that:

You can see demo of proposal sync from here with , password:melange2011 and type to find "Test Document 1" that is in GDocs account of testmelange user.