Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing overloaded global "type" from storage.acl. #156

Merged
merged 2 commits into from
Sep 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions gcloud/storage/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class Entity(object):
outside of using the factor methods on the :class:`ACL` object.
"""

def __init__(self, type, identifier=None):
def __init__(self, entity_type, identifier=None):
"""
:type type: string
:param type: The type of entity (ie, 'group' or 'user').
:type entity_type: string
:param entity_type: The type of entity (ie, 'group' or 'user').

:type identifier: string
:param identifier: The ID or e-mail of the entity.
Expand All @@ -103,7 +103,7 @@ def __init__(self, type, identifier=None):

self.identifier = identifier
self.roles = set([])
self.type = type
self.type = entity_type

def __str__(self):
if not self.identifier:
Expand Down Expand Up @@ -218,8 +218,8 @@ def entity_from_dict(self, entity_dict):
entity = self.all_authenticated()

elif '-' in entity:
type, identifier = entity.split('-', 1)
entity = self.entity(type=type, identifier=identifier)
entity_type, identifier = entity.split('-', 1)
entity = self.entity(entity_type=entity_type, identifier=identifier)

if not isinstance(entity, ACL.Entity):
raise ValueError('Invalid dictionary: %s' % entity_dict)
Expand Down Expand Up @@ -262,16 +262,17 @@ def add_entity(self, entity):

self.entities[str(entity)] = entity

def entity(self, type, identifier=None):
def entity(self, entity_type, identifier=None):
"""Factory method for creating an Entity.

If an entity with the same type and identifier already exists,
this will return a reference to that entity.
If not, it will create a new one and add it to the list
of known entities for this ACL.

:type type: string
:param type: The type of entity to create (ie, ``user``, ``group``, etc)
:type entity_type: string
:param entity_type: The type of entity to create
(ie, ``user``, ``group``, etc)

:type identifier: string
:param identifier: The ID of the entity (if applicable).
Expand All @@ -281,7 +282,7 @@ def entity(self, type, identifier=None):
:returns: A new Entity or a refernece to an existing identical entity.
"""

entity = ACL.Entity(type=type, identifier=identifier)
entity = ACL.Entity(entity_type=entity_type, identifier=identifier)
if self.has_entity(entity):
entity = self.get_entity(entity)
else:
Expand Down