Hi Jeff,
          I don't know why Python can't see the ConvertDataPart method
- I tried a few things with it to see if I could fix the problem.

Eventually, to help me progress a bit, I just inlined the logic at
line 92 in appengine.py where it was trying to call the function. The
program did what I wanted. Not a long term fix though, since the same
function is called above for a case I'm not hitting yet.

I tested on a Mac and a PC with new installs of the libraries and saw
the same behavior. Hopefully it's a trivial problem that you might be
able to figure out quickly.

Thanks.

Anton

On Sep 11, 12:06 am, amc <[EMAIL PROTECTED]> wrote:
> Hi,
>     Thanks for the information about the new api. I tried it out with
> the contacts api and ran into a problem. Here's the code ...
>
> #!/usr/bin/python
> import wsgiref.handlers
> import urllib
> from google.appengine.ext import webapp
> import gdata.service
> import gdata.contacts.service
> import gdata.alt.appengine
>
> class Lister(webapp.RequestHandler):
>
>   def get(self):
>
>     self.gd_client = gdata.contacts.service.ContactsService()
>
>     gdata.alt.appengine.run_on_appengine(self.gd_client)
>
>     self.gd_client.email = '[EMAIL PROTECTED]'
>     self.gd_client.password = '*******'
>     self.gd_client.source = 'GoogleInc-ContactsPythonSample-1'
>     self.gd_client.ProgrammaticLogin()
>
>     self.response.out.write('<body>')
>     self.response.out.write('<div id="main"/>')
>     self.response.out.write('</body>')
>
> def main():
>   application = webapp.WSGIApplication([('/.*', Lister),], debug=True)
>   wsgiref.handlers.CGIHandler().run(application)
>
> if __name__ == '__main__':
>   main()
>
> And this is the trace I see when it runs ...
>
> Traceback (most recent call last):
>   File "/Users/Anton/Desktop/GoogleAppEngineLauncher.app/Contents/
> Resources/GoogleAppEngine-default.bundle/Contents/Resources/
> google_appengine/google/appengine/ext/webapp/__init__.py", line 499,
> in __call__
>     handler.get(*groups)
>   File "/Users/Anton/mail/mail.py", line 42, in get
>     self.gd_client.ProgrammaticLogin()
>   File "/Users/Anton/mail/gdata/service.py", line 449, in
> ProgrammaticLogin
>     headers={'Content-Type':'application/x-www-form-urlencoded'})
>   File "/Users/Anton/mail/gdata/alt/appengine.py", line 92, in request
>     data_str = __ConvertDataPart(data)
> NameError: global name '_AppEngineHttpClient__ConvertDataPart' is not
> defined
>
> I'm new to app engine and python, so I may well have missed something.
> I'd be grateful for your advice.
>
> Thanks.
>
> Anton
>
> On Sep 10, 3:13 pm, "Jeff S (Google)" <[EMAIL PROTECTED]> wrote:
>
> > Hi moparthi,
>
> > I thought of a few suggestions that might help. The first is that the
> > atom and gdata directories from the gdata-python-client/src directory
> > need to be included in the top level directory for your app. The gdata
> > library source code will needs to be uploaded as part of your app.
> > This is my first guess as to why the imports would fail.
>
> > Also, there is an additional line which you must add to your code to
> > tell the gdata library that HTTP requests should use the App Engine
> > urlfetch API (since the default for the gdata library uses raw socket
> > connections which are not allowed in App Engine). In the latest
> > version of the gdata-python-client (version 1.2.0) you would do this:
>
> > import gdata.alt.appengine
> > ...
> > self.cal_client = gdata.calendar.service.CalendarService()
> > gdata.alt.appengine.run_on_appengine(self.cal_client)
>
> > Lastly, I noticed that you are using ClientLogin, which requires a
> > username and password, and these are being passed around in plaintext.
> > I strongly recommend that you switch to using AuthSub authorization
> > instead. I've written an article which explains how to use AuthSub
> > with App Engine which you can find 
> > herehttp://code.google.com/appengine/articles/gdata.html
>
> > Let me know how it goes :)
>
> > Jeff
>
> > On Sep 9, 12:34 am, moparthi <[EMAIL PROTECTED]> wrote:
>
> > > hi,
>
> > > I tried to use calendar service in cgi-script.
>
> > > This is my code
>
> > > try:
> > >   from xml.etree import ElementTree
> > > except ImportError:
> > >   from elementtree import ElementTree
>
> > > import gdata.calendar.service
> > > import gdata.service
> > > import atom.service
> > > import gdata.calendar
> > > ##import atom
> > > ##import getopt
> > > ##import sys
> > > ##import string
>
> > > import cgi, sys
> > > import cgitb; cgitb.enable()  # for troubleshooting
> > > import time
>
> > > ##print "Content-type: text/html"
> > > ##
> > > ##print """
> > > ##       <html>
> > > ##
> > > ##        <head><title>Sample Script</title></head>
> > > ##
> > > ##        <body>
> > > ##
> > > ##          <h3> Sample CGI Script </h3>
> > > ##      """
>
> > > sys.stderr = sys.stdout
>
> > > html =  """
>
> > >   <p>Previous message : %s</p>
> > >   <p> Time is %s</p>
> > >   <p> Age is %s</p>
> > >   <form action="" method="post">
> > >      Enter the User name : <input type="text" name="message"><br/>
> > >      Enter the Password &nbsp;: <input type="password" name="age">
> > >      Select a value :
> > >        <select name="dropdown>
> > >          <option value="RED">red</option>
> > >          <option value="ORANGE">orange</option>
> > >          <option value="BLUE">blue</option>
> > >        </select>
> > >      <input type="submit" value="Submit">
> > >   </form>
>
> > > </body>
>
> > > </html>
> > > """
>
> > > class CalendarExample:
>
> > >   def __init__(self):
> > >       print 'In Class'
> > >       print "You're talking to a %s server." % (sys.platform)
> > >       print "Version is %s " % (sys.version)
> > >       print "<br/>Path is %s" % (sys.path)
>
> > >   def login(self, email, password):
> > >     """Creates a CalendarService and provides ClientLogin auth details
> > > to it.
> > >     The email and password are required arguments for ClientLogin.
> > > The
> > >     CalendarService automatically sets the service to be 'cl', as is
> > >     appropriate for calendar.  The 'source' defined below is an
> > > arbitrary
> > >     string, but should be used to reference your name or the name of
> > > your
> > >     organization, the app name and version, with '-' between each of
> > > the three
> > >     values.  The account_type is specified to authenticate either
> > >     Google Accounts or Google Apps accounts.  See gdata.service or
> > >    http://code.google.com/apis/accounts/AuthForInstalledApps.htmlfor
> > > more
> > >     info on ClientLogin.  NOTE: ClientLogin should only be used for
> > > installed
> > >     applications and not for multi-user web applications."""
>
> > >     print "<h1>Hello</h1>"
> > >     print "<p>Id is %s " % (email,)
> > >     print "<p>Password is %s " % (password,)
>
> > >     self.cal_client = gdata.calendar.service.CalendarService()
> > >     self.cal_client.email = email
> > >     self.cal_client.password = password
> > >     self.cal_client.source = 'Google-Calendar_Python_Sample-1.0'
> > >     self.cal_client.ProgrammaticLogin()
>
> > > def main():
>
> > >   form = cgi.FieldStorage()
> > >   message = form.getvalue("message", "")
> > >   age = form.getvalue("age", "")
>
> > >   now = time.gmtime()
> > >   displayedtime = time.strftime("%A %d %B %Y, %X", now)
> > >   contentheader = "Content-type: text/html"
> > >   print contentheader
> > >   print html % (message, displayedtime, age)
>
> > >   sample = CalendarExample()
> > >   sample.login(message, age)
>
> > > if __name__ == '__main__':
> > > #  print '\n Main If condition'
> > >   main()
>
> > > when i tried to run in google app engine using command
> > > dev_appserver.py cgi
>
> > > it showing an error as
>
> > > importerror : No module named gdata.calendar.service
>
> > > can anyone help me how to use calendar service with cgi
>
> > > regards,
> > > moparthi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to