Django + xul  - woking fine.The code is bellow.


view.py :




from django import http


def index(request):
   resp = http.HttpResponse()
   resp.headers['Content-Type'] = 'application/vnd.mozilla.xul+xml'
   resp.write('<?xml version="1.0" encoding="UTF-8" ?>')
   resp.write('<?xml-stylesheet href="chrome://global/skin"
type="text/css"?>')
   resp.write('<window id="example-window" width="800" height="600"
title="test" xmlns:html="http://www.w3.org/1999/xhtml";
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";>')

   resp.write("""
                   <script>

           const SERVER_URL = "post/";


           function doLogin()
           {
                   req = new pythonRequest();
                   //req.add('0',username);
                   //req.add('1',password);

                   var response = req.execute();
           }

            function doClose()
           {
               window.close();
           }

           function pythonRequest()
           {
                   this.parms = new Array();
                   this.parmsIndex = 0;
                   this.execute = pythonRequestExecute;
                   this.add = pythonRequestAdd;
                   this.server = SERVER_URL;
           }

           function pythonRequestAdd(name,value)
           {
                   this.parms[this.parmsIndex] = new Pair(name,value);

                   this.parmsIndex++;
           }

           function pythonRequestExecute()
           {
                   var targetURL = this.server;

                   try {
                           var httpRequest = new XMLHttpRequest();
                   }catch (e){
                           alert('Error creating the connection!');
                           return;
                   }

                   try {

                           var txt="";
                           for(var i in this.parms) {
                                  txt =
txt+this.parms[i].name+'='+this.parms[i].value;
                           }

                           httpRequest.open("POST", targetURL, false,
null, null);

httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                           httpRequest.send(txt);
                   }catch (e){
                           alert('An error has occured calling the
external site: '+e);
                           return false;
                   }

                   switch(httpRequest.readyState) {
                           case 1,2,3:
                                   alert('Bad Ready State:
'+httpRequest.status);
                                   return false;
                           break;
                           case 4:
                                   if(httpRequest.status !=200) {
                                           alert('The server respond
with a bad status code: '+httpRequest.status);
                                           return false;
                                   } else {
                                           var response =
httpRequest.responseText;

                                   }
                           break;
                   }

                   return response;
           }

           function Pair(name,value)
           {
                   this.name = name;
                   this.value = value;
           }


           </script>
           <vbox flex="1"  align="center" pack="center" >
                           <grid>


                                   <columns>

                                           <column/>
                                           <column/>

                                   </columns>




                                   <rows>

                                       <row>
                     <label value="User" />
                     <hbox>
                       <textbox id="username" style="width:10em
font-size: 14px"/>
                       <spacer flex="1" />
                     </hbox>
                   </row>
                     <row>
                     <label value="Password" />
                     <hbox>
                       <textbox id="password" type="password"
style="width:10em font-size: 14px"/>
                       <spacer flex="1" />
                     </hbox>
                   </row>


                                   </rows>

                           </grid>
                           <spacer/>


                           <hbox  >

                           <spacer flex="1"/>

                                        <button label="Sign in"
oncommand="doLogin();return false;"/>

                                        <button id="cancel-button"
label="Cancel" oncommand="doLogin();return false;"/>

                   </hbox>


                   </vbox>

       """)

resp.write('</window>') return resp



thanks

Madhu Alagu


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to