Archive

Transifex

For last few days, I was working on implementing a feature where the users who log in through the social log in methods in Transifex can choose a username, when logging in for the first time. Logically, I had to add in a step in the transifex social_auth_pipeline to display the user with a form to enter the desired username, before the user is created. django-social-auth provides us with Partial Pipeline where one can halt the pipeline process and ask the user for more data, and then resume. As mentioned in the docs:

It’s possible to cut the pipeline process to return to the user asking for more data and resume the process later, to accomplish this add the entry social_auth.backends.pipeline.misc.save_status_to_session (or a similar implementation) to the pipeline setting before any entry that returns an HttpResponse instance

The example below can be used implement partial pipeline

SOCIAL_AUTH_PIPELINE = (
...
social_auth.backends.pipeline.misc.save_status_to_session,
app.pipeline.redirect_to_basic_user_data_form
...
)

After the pipeline resumes, by default the pipeline is resumed from the next entry after save_status_to_session but this can be modified by setting the following setting to the import path of the pipeline entry to resume processing

SOCIAL_AUTH_PIPELINE_RESUME_ENTRY = 'social_auth.backends.pipeline.misc.save_status_to_session'

This comes handy when the user inputs an invalid/duplicate data and one need to cut the pipeline process again. After implementing this feature, I submitted the patch to upstream and hope to get it accepted.

REFERENCE: http://django-social-auth.readthedocs.org/en/latest/pipeline.html

Advertisements

Hi there! It’s been a long time since my last blog post. In the break, I was facing my semester exams, and I felt better stay away from my laptop rather than books. Though other reason of not remaining online was my Nokia C5 mobile got pick-pocketed 😦 and I didn’t have any mode to remain online. After the my exam ended, I again bought the same mobile and started on working on transifex. I had already written some code before the exam so that anonymous users can access to the files through web-interface. But, mpessas and rtnpro suggested me to work on allowing anonymous access through the API and write some tests for the same.

So, after the exams this was my first task in hand, I went through the Transifex APIv2 docs and made some changes in the code to get the job done. I also wrote the test with the help of @rtnpro. I was also facing problem with the notification settings bar in the profile settings page. Though the ENABLE_NOTICES settings was set to True. The notification settings bar was not showing up. After the studying the code for the templatetag settings, I found out that the templatetag itself was the cause for the issue. Moving the templatetag inside the content_main block in templates/userena/base_userena.html solved the issue.

In the mean time, I read about the revised version of the Microsoft Translation API. Earlier, the Bing AppID was enough to get the work done. But now, the Bing AppID is deprecated and is no longer supported. To use the Microsoft Translator API, one has to obtain an access token using Client ID and Client Secret obtained after registering an application at Azure DataMarket and use it for the calls to the Microsoft Translator API. The process of obtaining the access token can be seen here . The Microsoft Translator API is well documented and it help me a lot. Currently, I am working on implementing the new Microsoft Translator API in transifex.

I am also currently working on the feature approved by jkal to we allow users to set their username after the first login through the social method in transifex (Facebook, Google, Twitter and LinkedIn).

Just like last year, this year’s Mukti was also filled with fun and frolic. Mukti is the annual FOSS festival organised by the GNU/Linux Users Group of NIT Durgapur. Mukti 2012 was held on 3-5th Februar 2012.There were lots of events like Codecraker, FreeMesh,FreePL etc. Students and Foss enthusiast from in and around Durgapur come to this three day festival.

On the first day, gaurav and I left for Mukti a bit lit along with some other 1st year students. On reaching the we met with rtnpro and after the inauguration ceremony, rtnpro talked to newbies and gave a comparatively small talk on django. In the evening, we went over to the KDE development workshop by Smit Shah, where he enlighted us his experiences in the KDE Community and how to contribute to it.

Next day, rtnpro, aavrug, chandan, and I, along with some guys from NIT DGP discussed on Transifex, mainly on how it works, what is it purpose, how Transifex is written etc. I also wrote some patches during the workshop and pushed it for review, we skipped the Android Development workshop by Ravi Vyas as it was very crowded so we decided to ship it for the hackfest. The following day, we geared up for the Django/Trasifex by Ratnadeep Debnath(rtnpro). He told us about the Transifex, how it started, said about the team, what does it does etc. He also showed the newbie how simple is too start off with contributing by solving bugs, fixing typos etc.

It was a great time, meeting with FOSSy people during Mukti and also met two of my old pals. I really applaud to all those who have put their hard work,labour and time to make this event a huge success and hope that MUKTI 2013 would be even bigger, greater than this year.

Last week, I started working on the ticket #789 which reported that there should be support for the xliff files with .xml extension. As it was an easy patch with few edits in the configuration file and tests I submitted the patch to upstream for review and they accepted it. 🙂
After that rtnpro directed /me to work on the ticket #673 which reported that there should be a RSS Feed for the project timeline. As I had already worked with RSS Feed in ASKBOT so I had a prior knowledge about the topic. But I went through the topic once again more deeply and got to a lot more things. It took sometime due the festive season in between but submitted the patch for review as soon as possible and got it accepted.
After that I started off ticket #578 but could not complete it as I found that there was a bug in the /project/add/ page which raised the NoReverseMatch exception so I reported this to rtnpro and started working on it and found some more bugs and a typo and finally resolved it altogether and submitted the patch. I also sent a patch regarding a bug in the Manage tab which was losing it’s selection after the sub menu item was pressed.

For some time now, after my exams got over I started hanging going through the source code of Transifex. After some time, I contacted rtnpro and he directed me to work on the ticket #808.
The ticket #808 reported that searching should be made possible not only in the source text but also in the translations.So, I had to go through Complex lookups with Q objects in order to write the patch. I submitted patch upstream for review and got it accepted.:)

What is Transifex?

Transifex is an open source platform for localization. It is a service offering users with an easy-to-use interface to submit translations to various projects hosted on a number of hosting platform types.

What is virtualenv?

virtualenv is a tool to build isolated Python environments. It’s a great way to quickly test new libraries without cluttering your global site-packages or run multiple projects on the same machine which depend on a particular library but not the same version of the library.

How to install virtualenv?

You can install the virtualenv by running
easy_install virtualenv
or
pip install virtualenv


You can install easy_install using:
pip install setuptools

How to activate virtualenv?

Once you have successfully installed virtualenv, you can use it to create virtual environments by running:
virtualenv --no-site-packages site


Activate the virtualenv using:
source site/bin/activate
or
. site/bin/activate

How to install Transifex?

Now create a fork of Transifex from bitbucket, clone the repository and install
cd site
hg clone https://bitbucket.org/indifex/transifex
cd transifex

python setup.py develop

But the latest tip requires Django==1.3.1,so to upgrade django use:
pip install Django --upgrade

To install the other modules(if required) in virtualenv using:
pip install <module name>

To install the userprofile module from the http://transifex.org/files/deps/ use:
pip install http://trac.transifex.org/files/deps/userprofile-0.6.tar.gz

To install the django-piston, for creating application programming interface(APIs) use:
easy_install django-piston
or
easy_install http://trac.transifex.org/files/deps/django-piston-0.2.3-devel-r278.tar.gz

How to configure Transifex?

Now to install the server use:
cd transifex
./manage.py txcreatedirs                       #Create necessary directories
./manage.py syncdb                                     # Setup DB tables, create superuser
./manage.py migrate                                   # Setup more DB tables

While running ./mange.py migrate, it raised a resources migration error, for that I removed the respective the resource migration file from resources/migrations to succeed migration.

./manage.py txlanguages                          # Create a standard set of languages
./manage.py txcreatenoticetypes       # Create a standard set of notice types
./manage.py collectstatic                     #Copy all the addons files to the static dir
./manage.py runserver 8000                   #Start the development server

Now that the server‘s running, visit http://127.0.0.1:8000/ with your Web browser.

References

http://help.transifex.net/
http://www.arthurkoziel.com/2008/10/22/working-virtualenv/

%d bloggers like this: