author | Sverre Rabbelier <srabbelier@gmail.com> |
Sun, 12 Oct 2008 00:08:54 +0000 | |
changeset 298 | c76a366c7ab4 |
parent 263 | 9b39d93b677f |
permissions | -rw-r--r-- |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
2 |
# |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
4 |
# |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
8 |
# |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
10 |
# |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
16 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
17 |
"""Document (Model) query functions. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
18 |
""" |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
19 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
21 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
251
8f23804302d0
Move path and link_name related functions and regex patterns to a new
Todd Larsen <tlarsen@google.com>
parents:
248
diff
changeset
|
22 |
'"Todd Larsen" <tlarsen@google.com>', |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
23 |
] |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
24 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
143
diff
changeset
|
25 |
|
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
26 |
import re |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
27 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
28 |
from google.appengine.ext import db |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
29 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
143
diff
changeset
|
30 |
from soc.logic import key_name |
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
31 |
from soc.logic import out_of_band |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
32 |
from soc.logic.site import id_user |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
33 |
|
263
9b39d93b677f
Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents:
251
diff
changeset
|
34 |
from soc.logic import model |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
143
diff
changeset
|
35 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
36 |
import soc.models.document |
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
37 |
|
248
95e0b84e71c5
Add missing blank line to follow PythonStyleGuide in document.py
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
225
diff
changeset
|
38 |
|
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
39 |
def getDocument(path, link_name=None): |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
40 |
"""Returns Document entity for a given path, or None if not found. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
41 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
42 |
Args: |
143
b419121f7b3e
FIxed documentation in soc/logic/document.py for getDocumentFromPath function
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
141
diff
changeset
|
43 |
path: a request path of the Document that uniquely identifies it |
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
44 |
link_name: optional link name to append to path (when supplied, |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
45 |
path is actually a "partial path" that needs to link name appended |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
46 |
to it) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
47 |
""" |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
48 |
# lookup by Doc:path key name |
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
49 |
name = key_name.nameDocument(path, link_name=link_name) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
50 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
143
diff
changeset
|
51 |
if name: |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
143
diff
changeset
|
52 |
document = soc.models.document.Document.get_by_key_name(name) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
53 |
else: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
54 |
document = None |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
55 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
56 |
return document |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
57 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
58 |
|
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
59 |
def getDocumentIfPath(path, link_name=None): |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
60 |
"""Returns Document entity for supplied path if one exists. |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
61 |
|
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
62 |
Args: |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
63 |
path: path used in URLs to identify document |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
64 |
|
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
65 |
Returns: |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
66 |
* None if path is false. |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
67 |
* Document entity that has supplied path |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
68 |
|
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
69 |
Raises: |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
70 |
out_of_band.ErrorResponse if path is not false, but no Document entity |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
71 |
with the supplied path exists in the Datastore |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
72 |
""" |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
73 |
if not path: |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
74 |
# exit without error, to let view know that link_name was not supplied |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
75 |
return None |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
76 |
|
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
77 |
path_doc = getDocument(path, link_name=link_name) |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
78 |
|
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
79 |
if path_doc: |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
80 |
# a Document has this path, so return that corresponding Document entity |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
81 |
return path_doc |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
82 |
|
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
83 |
# else: a path was supplied, but there is no Document that has it |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
84 |
raise out_of_band.ErrorResponse( |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
85 |
'There is no document with a "path" of "%s".' % path, status=404) |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
86 |
|
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
87 |
|
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
88 |
def updateOrCreateDocument(**document_properties): |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
89 |
"""Update existing Document entity, or create new one with supplied properties. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
90 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
91 |
Args: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
92 |
path: a request path of the Document that uniquely identifies it |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
93 |
**document_properties: keyword arguments that correspond to Document entity |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
94 |
properties and their values |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
95 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
96 |
Returns: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
97 |
the Document entity corresponding to the path, with any supplied |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
98 |
properties changed, or a new Document entity now associated with the |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
99 |
supplied path and properties. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
100 |
""" |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
101 |
# attempt to retrieve the existing Document |
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
102 |
document = getDocument(document_properties['partial_path'], |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
103 |
link_name=document_properties['link_name']) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
104 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
105 |
if not document: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
106 |
# document did not exist, so create one in a transaction |
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
107 |
name = key_name.nameDocument(document_properties['partial_path'], |
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
108 |
document_properties['link_name']) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
109 |
document = soc.models.document.Document.get_or_insert( |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
143
diff
changeset
|
110 |
name, **document_properties) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
111 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
112 |
# there is no way to be sure if get_or_insert() returned a new Document or |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
113 |
# got an existing one due to a race, so update with document_properties anyway, |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
114 |
# in a transaction |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
115 |
return soc.logic.model.updateModelProperties(document, **document_properties) |