Skip to content

Commit

Permalink
Can return projects from pages when parsing specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeboers committed Jun 5, 2015
1 parent 453b8b1 commit 08dcc80
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sgfs/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _data_from_path(sgfs, path, entity_types=None):
return (entities[0] if entities else None, data)


def parse_spec(sgfs, spec, entity_types=None):
def parse_spec(sgfs, spec, entity_types=None, project_from_page=False):

# We used to accept multiple parameters, but now we just take one.
if not isinstance(spec, str):
Expand Down Expand Up @@ -68,6 +68,8 @@ def parse_spec(sgfs, spec, entity_types=None):
if m:
page = sgfs.session.find_one('Page', [('id', 'is', int(m.group(1)))], ['entity_type', 'project'])
if page['entity_type'] != 'Project':
if project_from_page and page.get('project'):
return page['project']
raise ValueError('given URL is not a Project entity')
data = {}
_expand_entity(data, page['project'])
Expand Down

0 comments on commit 08dcc80

Please sign in to comment.