Exemplo n.º 1
0
def ShareWithUser(client, email, package):
    for resource in client.GetAllResources():
        if package == resource.title.text:
            acl_entry = gdata.docs.data.AclEntry(
                scope=gdata.acl.data.AclScope(value=email, type='user'),
                role=gdata.acl.data.AclRole(value='reader'),
            )
            try:
                client.add_acl_entry(resource,
                                     acl_entry,
                                     send_notifications=True)
                print 'Success'
            except gdata.client.Error:
                exit('Error')
Exemplo n.º 2
0
def CreateClient():
  """Create a Documents List Client."""
  client = gdata.docs.client.DocsClient(source=SampleConfig.APP_NAME)
  client.http_client.debug = SampleConfig.DEBUG
  # Authenticate the user with CLientLogin, OAuth, or AuthSub.
  try:
    client.client_login('*****@*****.**', 'vum-v0d7xaju', source=None, service='writely')
    doc = client.GetAllResources():
    acl_entry = gdata.docs.data.AclEntry(
    scope=gdata.acl.data.AclScope(value='*****@*****.**', type='user'),
    role=gdata.acl.data.AclRole(value='reader'),
    )
    client.AddAclEntry(doc, acl_entry, send_notification=False)
  except gdata.client.BadAuthentication:
    exit('Invalid user credentials given.')
  except gdata.client.Error:
    exit('Login Error')
  return client
Exemplo n.º 3
0
def GetAllResourcesSample():
  """Get and display all resources, using pagination."""
  client = CreateClient()
  # Unlike client.GetResources, this returns a list of resources
  for resource in client.GetAllResources():
    PrintResource(resource)