Re: [Mailman-Developers] GSOC 2015 :Mailman Client written in Javascript
![](https://secure.gravatar.com/avatar/b009b2809a98fc29d87d2ef8a9609005.jpg?s=120&d=mm&r=g)
Hi Abhishek,
If you are going to do this sort of development you will need to become familiar with tools for observing the traffic being sent from the web browser to the web server.
What sort of operating system are you using?
Right clicking in a browser window that you run your JavaScript code in will generally allow you to bring up Firebug or some similar set of developer tools. There will be a “network” option there somewhere that allows you to see what is being sent between browser and server. You will be able to observe the request headers at that point.
You should also install curl and become familiar with using it to send requests to the Mailman REST API. Make sure you have a good look through the curl options because there are lots of helpful options there for looking at headers etc.
If you are using Chrome there is a plugin called postman that allows you to send request to REST API’s. This is also helpful.
Generally when you are trying to diagnose problems talking to the Mailman REST API you should first use the tools mentioned above to make sure your request is structured properly. Once you are certain you can execute your request properly using one of the tools above, then it is time to try to make your JavaScript code send the same request. If your code is not working, use Firebug to observe the difference between what you are sending and what you made work using the command line tools.
If you are doing node.js or some other sort of server executed JavaScript you will need another tool for watching the network traffic. I presume you are running Mailman on a LInux machine. When diagnosing communications between client and server it is helopful on the Linux side to be able to see the network traffic passing to and from the Mailman REST API. To do so, I use the following Linux command:
sudo ngrep -W byline -d lo port 7001
This assumes your Mailman REST API is running on port 7001 which it probably is not - I don’t know which port you are running it on - you will have to do a "mailman info” command to find out.
It will take you a while to become familiar with the output of ngrep and see what is being sent, but it is worth the effort as this is the most direct route to solving many problem.
Finally, to solve the current issue that you have with basic authentication against the Mailman REST API you should just search google for +javascript +basic +auth +stackoverflow - surely there must be some good instructions out there somewhere for how to make basic auth work - it should be pretty straightforward.
thanks
as
On 6 Mar 2015, at 7:20 pm, Abhishek Kumar <abhi170893@gmail.com> wrote:
Hi,
Sorry for the same last 2 mails. Last one was sent accidentally. Are there any ideas regarding the issues i mentioned in them..? Abhilash..?
On Fri, Mar 6, 2015 at 2:38 AM, Abhishek Kumar <abhi170893@gmail.com> wrote:
Hi,
Thanks Aanand and Abhilash for the help and suggestions. I need further assistance:
I tried to write the connection class's rough javascript code. It works if i bypass the authentication. I have encoded/decoded the authentication data correctly ( as seemed from printing them and what python client generates through b64encode(auth.encode('utf-8')).decode('utf-8') ). If authentication is allowed, the javascript client shows "401, Unauthorized. The REST API requires authentication." This happens because the request.auth on line 68 in src/mailman/rest/root.py is None (see in this <http://bazaar.launchpad.net/~mailman-coders/mailman/3.0/view/head:/src/mailman/rest/root.py> file) even when i am passing the authentication data in the http header . However there are no issues when i use the python client through shell and everyhing works fine. I was unable to figure out the issue. Any ideas regarding what should i do here..? The js code(uses some nodejs) can be seen here <http://pastebin.com/isxPbsNk>.
Also i need some guidance on what should i do now towards applying for this project. Should i go on writing the javascript version by discussing it with the community..? And regarding what would go into my proposal, my current understanding stands at mainly writing javascript equivalent of everything present in _client.py(mailman client) alongwith documentation and tetsting. What more is required to be done in this project..?
On Thu, Mar 5, 2015 at 12:33 PM, Abhilash Raj <raj.abhilash1@gmail.com> wrote:
Hi Abhishek,
On Wednesday 04 March 2015 07:43 PM, Abhishek Kumar wrote:
Hi,
I was able to setup the mailman (Core, postorius, mailman.client, postorius_standalone) by downloading them individually. Also with superuser, i can create domains. I have some questions:
- When i try to create list i get : HTTP Error 500: A server error occurred. Please contact the administrator
Try to find out what error is raised, check the logs in var/logs/mailman.log . This error is very common due to the absence to postmap command which mailman uses to create postfix maps. Either you can set your mta to nullmta by adding the following in yout mailman.cfg in var/etc/
[mta] incoming: mailman.mta.null.NullMTA outgoing: mailman.mta.null.NullMTA
or simply install postfix.
- Though i am able to create domain using postorius ui, i am unable to do it by directly using the mailman.client. The development.rst doc says "python manage.py mmclient" can be used for the purpose. But after doing this no client object is created. I also tried tried the way given mailmanclient/docs/using.rst < http://bazaar.launchpad.net/~mailman-coders/mailman.client/trunk/view/head:/...
with port 8001. This creates client , but that object is unable to talk to the rest server.
Just saying that "object is unable to talk to the rest server" doesn't help. Make a habit of mentioning the complete traceback from logs when you have errors. Do you get a
Mailman API Error
? If yes, check that your mailman is running. If not, start it usingmailman start
command.
- Is what i installed using lp:mailman the mailman core..? and this handles the rest requests..?
Yes!
- Is there more documentation online other than that available in the doc folders of the projects..? I searched online but didn't get any developer type documentation.
No, the same documentation is available on readthedocs in a html format.
- If i make any changes in the code, what's the best way to make them reflected in the mailman..? run "python setup.py develop" for that project..?
You don't need to do anything if you ran
python setup.py develop
to set it up first time. If you usedpython setup.py install
then you need to run that again to reflect your changes.On Wed, Mar 4, 2015 at 2:41 PM, Abhilash Raj <raj.abhilash1@gmail.com> wrote:
On Wednesday 04 March 2015 02:01 PM, Abhishek Kumar wrote:
Hi,
Using the viurtualenv, i was able to complete the setup guide. But i am required to login at http://localhost:8000/ and there is no option to register. So i logged in using Mozilla persona. But even after that i am not getting any options to create domains and list as described here
Are you using mailman-bundler? It does not work right now! For development you'd have to download and setup each projects (Core, postorius, mailman.client, postorius_standalone) from launchpad.
Also, only superuser is allowed to create domains. You can create one in django (postorius_standalone) using the command:
$ python manage.py createsuperuser
Then you have to login as a superuser using the login credentials given or through persona.
-- thanks, Abhilash Raj
-- thanks, Abhilash Raj
-- Thanks, Abhishek Kumar
-- Thanks, Abhishek Kumar
Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/andrew.stuart%40s...
Security Policy: http://wiki.list.org/x/QIA9
![](https://secure.gravatar.com/avatar/a5f3aff8990dd0bf7a18888b31426c1c.jpg?s=120&d=mm&r=g)
Hi,
Thanks for the suggestions Andrew. Using ngrep i found that i was using authentication key in header instead of authorization. After correcting it, the js client runs successfully..! :) I have tried curl in past and will see how it could be helpful to me while working on this task.
Now that the authentication is resolved, i want to work forward. Some questions:
- When we talk about the javascript version, is usage of frameworks like jquery suggested..? Till now i have experience of using javascript only in webpages. But here i am writing a client which is not supposed to run in browser. Please correct me if i am wrong. Currently postorius uses the mailman.client to talk to the rest api. How would it be able to use the client in js..? Or the development js client is for another purpose..? If yes , what's that and how the js client would integrate with the mailman which is python based.
2)I asked this in the 2nd last mail but it got hidden in the duplicate last mail. I need some guidance on what should i do now towards applying for this project. Should i go on writing the javascript version by discussing it with the community..? And regarding what would go into my proposal, my current understanding stands at mainly writing javascript equivalent of everything present in _client.py(mailman client) alongwith documentation and tetsting. What more is required to be done in this project..?
On Fri, Mar 6, 2015 at 2:38 PM, Andrew Stuart < andrew.stuart@supercoders.com.au> wrote:
Hi Abhishek,
If you are going to do this sort of development you will need to become familiar with tools for observing the traffic being sent from the web browser to the web server.
What sort of operating system are you using?
Right clicking in a browser window that you run your JavaScript code in will generally allow you to bring up Firebug or some similar set of developer tools. There will be a “network” option there somewhere that allows you to see what is being sent between browser and server. You will be able to observe the request headers at that point.
You should also install curl and become familiar with using it to send requests to the Mailman REST API. Make sure you have a good look through the curl options because there are lots of helpful options there for looking at headers etc.
If you are using Chrome there is a plugin called postman that allows you to send request to REST API’s. This is also helpful.
Generally when you are trying to diagnose problems talking to the Mailman REST API you should first use the tools mentioned above to make sure your request is structured properly. Once you are certain you can execute your request properly using one of the tools above, then it is time to try to make your JavaScript code send the same request. If your code is not working, use Firebug to observe the difference between what you are sending and what you made work using the command line tools.
If you are doing node.js or some other sort of server executed JavaScript you will need another tool for watching the network traffic. I presume you are running Mailman on a LInux machine. When diagnosing communications between client and server it is helopful on the Linux side to be able to see the network traffic passing to and from the Mailman REST API. To do so, I use the following Linux command:
sudo ngrep -W byline -d lo port 7001
This assumes your Mailman REST API is running on port 7001 which it probably is not - I don’t know which port you are running it on - you will have to do a "mailman info” command to find out.
It will take you a while to become familiar with the output of ngrep and see what is being sent, but it is worth the effort as this is the most direct route to solving many problem.
Finally, to solve the current issue that you have with basic authentication against the Mailman REST API you should just search google for +javascript +basic +auth +stackoverflow - surely there must be some good instructions out there somewhere for how to make basic auth work - it should be pretty straightforward.
thanks
as
On 6 Mar 2015, at 7:20 pm, Abhishek Kumar <abhi170893@gmail.com> wrote:
Hi,
Sorry for the same last 2 mails. Last one was sent accidentally. Are there any ideas regarding the issues i mentioned in them..? Abhilash..?
On Fri, Mar 6, 2015 at 2:38 AM, Abhishek Kumar <abhi170893@gmail.com> wrote:
Hi,
Thanks Aanand and Abhilash for the help and suggestions. I need further assistance:
I tried to write the connection class's rough javascript code. It works if i bypass the authentication. I have encoded/decoded the authentication data correctly ( as seemed from printing them and what python client generates through b64encode(auth.encode('utf-8')).decode('utf-8') ). If authentication is allowed, the javascript client shows "401, Unauthorized. The REST API requires authentication." This happens because the request.auth on line 68 in src/mailman/rest/root.py is None (see in this < http://bazaar.launchpad.net/~mailman-coders/mailman/3.0/view/head:/src/mailman/rest/root.py> file) even when i am passing the authentication data in the http header . However there are no issues when i use the python client through shell and everyhing works fine. I was unable to figure out the issue. Any ideas regarding what should i do here..? The js code(uses some nodejs) can be seen here <http://pastebin.com/isxPbsNk>.
Also i need some guidance on what should i do now towards applying for this project. Should i go on writing the javascript version by discussing it with the community..? And regarding what would go into my proposal, my current understanding stands at mainly writing javascript equivalent of everything present in _client.py(mailman client) alongwith documentation and tetsting. What more is required to be done in this project..?
On Thu, Mar 5, 2015 at 12:33 PM, Abhilash Raj <raj.abhilash1@gmail.com> wrote:
Hi Abhishek,
On Wednesday 04 March 2015 07:43 PM, Abhishek Kumar wrote:
Hi,
I was able to setup the mailman (Core, postorius, mailman.client, postorius_standalone) by downloading them individually. Also with superuser, i can create domains. I have some questions:
- When i try to create list i get : HTTP Error 500: A server error occurred. Please contact the administrator
Try to find out what error is raised, check the logs in var/logs/mailman.log . This error is very common due to the absence to postmap command which mailman uses to create postfix maps. Either you can set your mta to nullmta by adding the following in yout mailman.cfg in var/etc/
[mta] incoming: mailman.mta.null.NullMTA outgoing: mailman.mta.null.NullMTA
or simply install postfix.
- Though i am able to create domain using postorius ui, i am unable to do it by directly using the mailman.client. The development.rst doc says "python manage.py mmclient" can be used for the purpose. But after doing this no client object is created. I also tried tried the way given mailmanclient/docs/using.rst <
http://bazaar.launchpad.net/~mailman-coders/mailman.client/trunk/view/head:/...
with port 8001. This creates client , but that object is unable to talk to
the
rest server.
Just saying that "object is unable to talk to the rest server" doesn't help. Make a habit of mentioning the complete traceback from logs when you have errors. Do you get a
Mailman API Error
? If yes, check that your mailman is running. If not, start it usingmailman start
command.
- Is what i installed using lp:mailman the mailman core..? and this handles the rest requests..?
Yes!
- Is there more documentation online other than that available in the doc folders of the projects..? I searched online but didn't get any developer type documentation.
No, the same documentation is available on readthedocs in a html format.
- If i make any changes in the code, what's the best way to make them reflected in the mailman..? run "python setup.py develop" for that project..?
You don't need to do anything if you ran
python setup.py develop
to set it up first time. If you usedpython setup.py install
then you need to run that again to reflect your changes.On Wed, Mar 4, 2015 at 2:41 PM, Abhilash Raj <raj.abhilash1@gmail.com> wrote:
On Wednesday 04 March 2015 02:01 PM, Abhishek Kumar wrote:
Hi,
Using the viurtualenv, i was able to complete the setup guide. But i am required to login at http://localhost:8000/ and there is no option to register. So i logged in using Mozilla persona. But even after that i am not getting any options to create domains and list as described here
Are you using mailman-bundler? It does not work right now! For development you'd have to download and setup each projects (Core, postorius, mailman.client, postorius_standalone) from launchpad.
Also, only superuser is allowed to create domains. You can create one in django (postorius_standalone) using the command:
$ python manage.py createsuperuser
Then you have to login as a superuser using the login credentials given or through persona.
-- thanks, Abhilash Raj
-- thanks, Abhilash Raj
-- Thanks, Abhishek Kumar
-- Thanks, Abhishek Kumar
Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/andrew.stuart%40s...
Security Policy: http://wiki.list.org/x/QIA9
-- Thanks, Abhishek Kumar
participants (2)
-
Abhishek Kumar
-
Andrew Stuart