Skip to content

Commit

Permalink
Add a location property to the entities
Browse files Browse the repository at this point in the history
Build the location, based on its kind location and their uuid
  • Loading branch information
alvarolopez committed Mar 5, 2015
1 parent 61e05ea commit ad57496
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ooi/occi/core/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,7 @@ def title(self):
@title.setter
def title(self, value):
self.attributes["occi.core.title"].value = value

@property
def location(self):
return helpers.join_url(self.kind.location, self.id)
6 changes: 6 additions & 0 deletions ooi/occi/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ def check_type(obj_list, obj_type):

if not all([isinstance(i, obj_type) for i in obj_list]):
raise TypeError('object must be of class %s' % obj_type)


def join_url(prefix, remainder, fragments=None):
if fragments:
remainder = "%s#%s" % (remainder, fragments)
return urlparse.urljoin(prefix, remainder)

0 comments on commit ad57496

Please sign in to comment.