equal
deleted
inserted
replaced
29 |
29 |
30 from soc.logic import key_name |
30 from soc.logic import key_name |
31 from soc.logic import out_of_band |
31 from soc.logic import out_of_band |
32 from soc.logic.site import id_user |
32 from soc.logic.site import id_user |
33 |
33 |
34 import soc.logic.model |
34 from soc.logic import model |
35 |
35 |
36 import soc.models.document |
36 import soc.models.document |
37 import soc.models.work |
|
38 |
37 |
39 |
38 |
40 def getDocument(path, link_name=None): |
39 def getDocument(path, link_name=None): |
41 """Returns Document entity for a given path, or None if not found. |
40 """Returns Document entity for a given path, or None if not found. |
42 |
41 |
112 |
111 |
113 # there is no way to be sure if get_or_insert() returned a new Document or |
112 # there is no way to be sure if get_or_insert() returned a new Document or |
114 # got an existing one due to a race, so update with document_properties anyway, |
113 # got an existing one due to a race, so update with document_properties anyway, |
115 # in a transaction |
114 # in a transaction |
116 return soc.logic.model.updateModelProperties(document, **document_properties) |
115 return soc.logic.model.updateModelProperties(document, **document_properties) |
117 |
|
118 |
|
119 def getWorksForOffsetAndLimit(offset=0, limit=0, cls=soc.models.work.Work): |
|
120 """Returns Works for given offset and limit or None if not found. |
|
121 |
|
122 Args: |
|
123 offset: offset in entities list which defines first entity to return |
|
124 limit: max amount of entities to return |
|
125 cls: Model class of items to return (including sub-classes of that type); |
|
126 default is Work |
|
127 """ |
|
128 query = db.GqlQuery( |
|
129 'SELECT * FROM Work WHERE inheritance_line = :1 ORDER BY title', |
|
130 key_name.getFullClassName(cls)) |
|
131 |
|
132 # Fetch one more to see if there should be a 'next' link |
|
133 return query.fetch(limit+1, offset) |
|