├── demos
├── quotas
│ └── backend
│ │ ├── quotas
│ │ ├── __init__.py
│ │ └── main.py
│ │ ├── quotas.json
│ │ ├── README
│ │ ├── backends.yaml
│ │ └── app.yaml
├── tunes_db
│ ├── client
│ │ ├── music_service.descriptor
│ │ ├── appengine_config.py
│ │ ├── base.css
│ │ ├── albums.html
│ │ ├── app.yaml
│ │ ├── tunes_db.py
│ │ ├── album.html
│ │ ├── artist.html
│ │ ├── base.html
│ │ ├── album_search.html
│ │ ├── artists.html
│ │ └── fetch_descriptor.py
│ ├── server
│ │ ├── appengine_config.py
│ │ ├── main.py
│ │ ├── app.yaml
│ │ ├── services.py
│ │ ├── index.yaml
│ │ ├── datastore_test_util.py
│ │ ├── model_test.py
│ │ └── model.py
│ └── README
├── appstats
│ ├── protorpc_appstats
│ │ ├── appstats.descriptor
│ │ ├── main.py
│ │ └── __init__.py
│ └── README
├── guestbook
│ ├── client
│ │ ├── app.yaml
│ │ ├── index.yaml
│ │ ├── appengine_config.py
│ │ ├── main.py
│ │ └── guestbook.py
│ ├── server
│ │ ├── app.yaml
│ │ ├── index.yaml
│ │ ├── appengine_config.py
│ │ └── guestbook.py
│ └── README
├── experimental
│ └── wsgi
│ │ ├── app.yaml
│ │ ├── services.py
│ │ └── README
├── echo
│ ├── appengine_config.py
│ ├── app.yaml
│ ├── main.py
│ ├── README
│ └── services.py
└── hello
│ └── server
│ ├── appengine_config.py
│ ├── app.yaml
│ ├── README
│ └── services.py
├── MANIFEST.in
├── README.md
├── .travis.yml
├── tox.ini
├── protorpc
├── google_imports.py
├── wsgi
│ ├── __init__.py
│ ├── util.py
│ └── service_test.py
├── non_sdk_imports.py
├── webapp
│ ├── __init__.py
│ ├── google_imports.py
│ ├── forms_test.py
│ └── forms.py
├── experimental
│ ├── __init__.py
│ └── parser
│ │ ├── test.proto
│ │ ├── pyprotobuf.g
│ │ ├── protobuf_lexer.g
│ │ └── protobuf.g
├── __init__.py
├── static
│ ├── forms.html
│ ├── methods.html
│ ├── base.html
│ └── jquery.json-2.2.min.js
├── protorpc_test.proto
├── message_types_test.py
├── generate.py
├── message_types.py
├── registry_test.py
├── generate_proto.py
├── generate_test.py
├── end2end_test.py
├── generate_proto_test.py
├── generate_python.py
└── registry.py
├── .gitignore
├── experimental
└── javascript
│ ├── build.sh
│ ├── closure
│ ├── debug
│ │ └── error.js
│ ├── xmlhttpfactory.js
│ ├── wrapperxmlhttpfactory.js
│ └── xmlhttp.js
│ ├── util.js
│ └── descriptor.js
├── setup.py
└── ez_setup.py
/demos/quotas/backend/quotas/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include LICENSE
2 | include *.py
3 | include protorpc/*.py
4 |
--------------------------------------------------------------------------------
/demos/tunes_db/client/music_service.descriptor:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/protorpc/HEAD/demos/tunes_db/client/music_service.descriptor
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ProtoRPC
2 | --------
3 |
4 | [](https://travis-ci.org/google/protorpc)
5 |
--------------------------------------------------------------------------------
/demos/appstats/protorpc_appstats/appstats.descriptor:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/protorpc/HEAD/demos/appstats/protorpc_appstats/appstats.descriptor
--------------------------------------------------------------------------------
/demos/guestbook/client/app.yaml:
--------------------------------------------------------------------------------
1 | application: postservice-client
2 | version: 1
3 | runtime: python
4 | api_version: 1
5 |
6 | handlers:
7 | - url: .*
8 | script: main.py
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: python
2 | python:
3 | - 2.7
4 | - 3.6
5 | sudo: false
6 | install: pip install tox-travis
7 | script: tox
8 | notifications:
9 | email: false
10 |
--------------------------------------------------------------------------------
/demos/guestbook/server/app.yaml:
--------------------------------------------------------------------------------
1 | application: postservice-demo
2 | version: 1
3 | runtime: python
4 | api_version: 1
5 |
6 | handlers:
7 |
8 | - url: .*
9 | script: guestbook.py
10 |
--------------------------------------------------------------------------------
/demos/quotas/backend/quotas.json:
--------------------------------------------------------------------------------
1 | {
2 | "buckets": [
3 | { "name": "DISK", "initial_tokens": 1000000 },
4 | { "name": "EMAILS", "initial_tokens": 20, "refresh_every": 3600 }
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/demos/experimental/wsgi/app.yaml:
--------------------------------------------------------------------------------
1 | application: experimental-wsgi
2 | version: 1
3 | api_version: 1
4 | runtime: python
5 |
6 | handlers:
7 |
8 | - url: /protorpc.*
9 | script: services.py
10 |
--------------------------------------------------------------------------------
/tox.ini:
--------------------------------------------------------------------------------
1 | [tox]
2 | envlist = py27,py36
3 |
4 | [testenv]
5 | deps = nose
6 | mox
7 | simplejson
8 | six
9 | unittest2
10 | commands = nosetests protorpc/message_types_test.py protorpc/messages_test.py protorpc/protojson_test.py
11 |
--------------------------------------------------------------------------------
/protorpc/google_imports.py:
--------------------------------------------------------------------------------
1 | """Dynamically decide from where to import other SDK modules.
2 |
3 | All other protorpc code should import other SDK modules from
4 | this module. If necessary, add new imports here (in both places).
5 | """
6 |
7 | __author__ = 'yey@google.com (Ye Yuan)'
8 |
9 | # pylint: disable=g-import-not-at-top
10 | # pylint: disable=unused-import
11 |
12 | try:
13 | from google.net.proto import ProtocolBuffer
14 | except ImportError:
15 | pass
16 |
--------------------------------------------------------------------------------
/demos/guestbook/client/index.yaml:
--------------------------------------------------------------------------------
1 | indexes:
2 |
3 | # AUTOGENERATED
4 |
5 | # This index.yaml is automatically updated whenever the dev_appserver
6 | # detects that a new type of query is run. If you want to manage the
7 | # index.yaml file manually, remove the above marker line (the line
8 | # saying "# AUTOGENERATED"). If you want to manage some indexes
9 | # manually, move them above the marker line. The index.yaml file is
10 | # automatically uploaded to the admin console when you next deploy
11 | # your application using appcfg.py.
12 |
--------------------------------------------------------------------------------
/demos/guestbook/server/index.yaml:
--------------------------------------------------------------------------------
1 | indexes:
2 |
3 | # AUTOGENERATED
4 |
5 | # This index.yaml is automatically updated whenever the dev_appserver
6 | # detects that a new type of query is run. If you want to manage the
7 | # index.yaml file manually, remove the above marker line (the line
8 | # saying "# AUTOGENERATED"). If you want to manage some indexes
9 | # manually, move them above the marker line. The index.yaml file is
10 | # automatically uploaded to the admin console when you next deploy
11 | # your application using appcfg.py.
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # python .gitignore, from http://github.com/github/gitignore
2 |
3 |
4 | # Byte-compiled / optimized / DLL files
5 | __pycache__/
6 | *.py[cod]
7 |
8 | # C extensions
9 | *.so
10 |
11 | # Distribution / packaging
12 | .Python
13 | env/
14 | build/
15 | develop-eggs/
16 | dist/
17 | downloads/
18 | eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 |
28 | # Unit test / coverage reports
29 | htmlcov/
30 | .tox/
31 | .coverage
32 | .cache
33 | nosetests.xml
34 | coverage.xml
35 |
36 | # Jetbrains IDE directories
37 | .idea/
38 |
--------------------------------------------------------------------------------
/protorpc/wsgi/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
--------------------------------------------------------------------------------
/experimental/javascript/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mkdir -p build/
4 | java -jar compiler.jar \
5 | --compilation_level ADVANCED_OPTIMIZATIONS \
6 | --generate_exports \
7 | --output_wrapper="(function(){%output%})();" \
8 | --warning_level VERBOSE \
9 | --js ./closure/base.js \
10 | --js ./closure/debug/error.js \
11 | --js ./closure/string/string.js \
12 | --js util.js \
13 | --js ./closure/json.js \
14 | --js ./closure/xmlhttpfactory.js \
15 | --js ./closure/wrapperxmlhttpfactory.js \
16 | --js ./closure/xmlhttp.js \
17 | --js messages.js \
18 | --js descriptor.js \
19 | --js protorpc.js \
20 | > build/protorpc_lib.js
21 |
--------------------------------------------------------------------------------
/demos/tunes_db/server/appengine_config.py:
--------------------------------------------------------------------------------
1 | def webapp_add_wsgi_middleware(app):
2 | """Configure additional middlewares for webapp.
3 |
4 | This function is called automatically by webapp.util.run_wsgi_app
5 | to give the opportunity for an application to register additional
6 | wsgi middleware components.
7 |
8 | See http://http://code.google.com/appengine/docs/python/tools/appstats.html
9 | for more information about configuring and running appstats.
10 | """
11 | from google.appengine.ext.appstats import recording
12 | app = recording.appstats_wsgi_middleware(app)
13 | return app
14 |
15 | import os
16 | import sys
17 |
18 | sys.path.insert(0, os.path.dirname(__file__))
19 |
--------------------------------------------------------------------------------
/protorpc/non_sdk_imports.py:
--------------------------------------------------------------------------------
1 | """Dynamically decide from where to import other non SDK Google modules.
2 |
3 | All other protorpc code should import other non SDK modules from
4 | this module. If necessary, add new imports here (in both places).
5 | """
6 |
7 | __author__ = 'yey@google.com (Ye Yuan)'
8 |
9 | # pylint: disable=g-import-not-at-top
10 | # pylint: disable=unused-import
11 |
12 | try:
13 | from google.protobuf import descriptor
14 | normal_environment = True
15 | except ImportError:
16 | normal_environment = False
17 |
18 | if normal_environment:
19 | from google.protobuf import descriptor_pb2
20 | from google.protobuf import message
21 | from google.protobuf import reflection
22 |
--------------------------------------------------------------------------------
/protorpc/webapp/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | __author__ = 'rafek@google.com (Rafe Kaplan)'
19 |
--------------------------------------------------------------------------------
/protorpc/webapp/google_imports.py:
--------------------------------------------------------------------------------
1 | """Dynamically decide from where to import other SDK modules.
2 |
3 | All other protorpc.webapp code should import other SDK modules from
4 | this module. If necessary, add new imports here (in both places).
5 | """
6 |
7 | __author__ = 'yey@google.com (Ye Yuan)'
8 |
9 | # pylint: disable=g-import-not-at-top
10 | # pylint: disable=unused-import
11 |
12 | import os
13 | import sys
14 |
15 | try:
16 | from google.appengine import ext
17 | normal_environment = True
18 | except ImportError:
19 | normal_environment = False
20 |
21 |
22 | if normal_environment:
23 | from google.appengine.ext import webapp
24 | from google.appengine.ext.webapp import util as webapp_util
25 | from google.appengine.ext.webapp import template
26 |
--------------------------------------------------------------------------------
/demos/echo/appengine_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | import os
19 | import sys
20 |
21 | sys.path.insert(0, os.path.dirname(__file__))
22 |
--------------------------------------------------------------------------------
/demos/guestbook/client/appengine_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | import os
19 | import sys
20 |
21 | sys.path.insert(0, os.path.dirname(__file__))
22 |
--------------------------------------------------------------------------------
/demos/guestbook/server/appengine_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | import os
19 | import sys
20 |
21 | sys.path.insert(0, os.path.dirname(__file__))
22 |
--------------------------------------------------------------------------------
/demos/hello/server/appengine_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | import os
19 | import sys
20 |
21 | sys.path.insert(0, os.path.dirname(__file__))
22 |
--------------------------------------------------------------------------------
/demos/tunes_db/client/appengine_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | import os
19 | import sys
20 |
21 | sys.path.insert(0, os.path.dirname(__file__))
22 |
--------------------------------------------------------------------------------
/demos/tunes_db/client/base.css:
--------------------------------------------------------------------------------
1 |
16 |
17 | thead {
18 | background: lightgrey;
19 | }
20 |
21 | .error_message {
22 | color: red;
23 | text-indent: 0.25in;
24 | }
25 |
--------------------------------------------------------------------------------
/demos/quotas/backend/README:
--------------------------------------------------------------------------------
1 | Quota Service
2 | =============
3 |
4 | It is possible to set up a quota service in your own application by following
5 | these steps:
6 |
7 | 1) Make a copy of the contents of this directory, including subdirectories
8 | for use as a custom backend of any client application that will use it.
9 |
10 | 2) Modify app.yaml:
11 | a. Change the application to the name of your application.
12 | b. Change the version to one that is appropriate for your application.
13 |
14 | 3) Edit quotas.js so that its settings are appropriate for your application.
15 | The format of the quotas.js file is a JSON encoded ProtoRPC message
16 | as defined by quotas.service.QuotaConfig of this demo.
17 |
18 | TODO: Define an easy to use client library.
19 |
--------------------------------------------------------------------------------
/protorpc/experimental/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | """Main module for ProtoRPC package."""
19 |
20 | __author__ = 'rafek@google.com (Rafe Kaplan)'
21 |
--------------------------------------------------------------------------------
/protorpc/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | """Main module for ProtoRPC package."""
19 |
20 | __author__ = 'rafek@google.com (Rafe Kaplan)'
21 | __version__ = '1.0'
22 |
--------------------------------------------------------------------------------
/demos/quotas/backend/backends.yaml:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | backends:
19 |
20 | - name: quota-server
21 | class: B1
22 | instances: 1
23 | start: /quota-service/start
24 | options: dynamic
25 |
26 |
27 |
--------------------------------------------------------------------------------
/demos/hello/server/app.yaml:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | application: hello-service-demo
19 | version: 1
20 | api_version: 1
21 | runtime: python
22 |
23 | handlers:
24 |
25 | - url: .*
26 | script: services.py
27 |
28 |
--------------------------------------------------------------------------------
/demos/experimental/wsgi/services.py:
--------------------------------------------------------------------------------
1 | from google.appengine.ext.webapp import util
2 |
3 | from protorpc.experimental import wsgi_service
4 | from protorpc.experimental import util as wsgi_util
5 | from protorpc import protobuf
6 | from protorpc import protojson
7 |
8 | from protorpc import registry
9 |
10 | protocols = wsgi_util.Protocols()
11 | protocols.add_protocol(protobuf, 'protobuf')
12 | protocols.add_protocol(protojson, 'json')
13 |
14 | reg = {'/protorpc': registry.RegistryService}
15 | registry_service = registry.RegistryService.new_factory(reg)
16 | application = wsgi_service.service_app(registry_service,
17 | '/protorpc',
18 | protocols=protocols)
19 |
20 |
21 | def main():
22 | util.run_bare_wsgi_app(application)
23 |
24 |
25 | if __name__ == '__main__':
26 | main()
27 |
--------------------------------------------------------------------------------
/demos/echo/app.yaml:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | application: echo-service-demo
19 | version: 1
20 | api_version: 1
21 | runtime: python
22 |
23 | handlers:
24 |
25 | - url: /
26 | script: main.py
27 |
28 | - url: /.+
29 | script: services.py
30 |
31 |
--------------------------------------------------------------------------------
/demos/tunes_db/client/albums.html:
--------------------------------------------------------------------------------
1 |
16 |
17 | {% extends "album_search.html" %}
18 |
19 | {% block top %}
20 |
21 |
25 |
26 | {% endblock %}
27 |
--------------------------------------------------------------------------------
/demos/quotas/backend/app.yaml:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | application: quota-server-demo
19 | version: 1
20 | api_version: 1
21 | runtime: python
22 |
23 | handlers:
24 |
25 | - url: /protorpc.*
26 | script: quotas/main.py
27 |
28 | - url: /quota-service.*
29 | script: quotas/main.py
30 |
31 |
32 |
--------------------------------------------------------------------------------
/protorpc/experimental/parser/test.proto:
--------------------------------------------------------------------------------
1 | /* !/usr/bin/env python
2 | *
3 | * Copyright 2011 Google Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package a.b.c;
18 |
19 | import "abc.def";
20 | import "from/here";
21 |
22 | message MyMessage {
23 | required int64 thing = 1 [a="b"];
24 | optional group whatever = 2 {
25 | repeated int64 thing = 1;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/demos/tunes_db/client/app.yaml:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | application: tunes-db-client
19 | version: 1
20 | api_version: 1
21 | runtime: python
22 |
23 | handlers:
24 |
25 | - url: /(.*\.(png|css|js))
26 | static_files: \1
27 | upload: (.*\.(png|css|js))
28 |
29 | - url: /.*
30 | script: main.py
31 |
32 |
--------------------------------------------------------------------------------
/demos/tunes_db/client/tunes_db.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | """Client library for tunes_db service."""
19 |
20 | import os
21 |
22 | from protorpc import definition
23 |
24 | definition.import_file_set(os.path.join(os.path.dirname(__file__),
25 | 'music_service.descriptor'))
26 |
--------------------------------------------------------------------------------
/protorpc/static/forms.html:
--------------------------------------------------------------------------------
1 |
16 |
17 | {% extends 'base.html' %}
18 |
19 | {% block title %}ProtoRPC Methods for {{hostname|escape}}{% endblock %}
20 |
21 | {% block top %}
22 |
27 | {% endblock %}
28 |
29 | {% block call %}
30 | loadServices(showMethods);
31 | {% endblock %}
32 |
--------------------------------------------------------------------------------
/demos/echo/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | __author__ = 'rafek@google.com (Rafe Kaplan)'
19 |
20 | import appengine_config
21 |
22 | from google.appengine.ext import webapp
23 | from google.appengine.ext.webapp import util
24 |
25 |
26 | application = webapp.WSGIApplication(
27 | [('/', webapp.RedirectHandler.new_factory('/protorpc/form'))],
28 | debug=True)
29 |
30 |
31 | def main():
32 | util.run_wsgi_app(application)
33 |
34 |
35 | if __name__ == '__main__':
36 | main()
37 |
--------------------------------------------------------------------------------
/demos/tunes_db/server/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | __author__ = 'rafek@google.com (Rafe Kaplan)'
19 |
20 | import appengine_config
21 |
22 | from google.appengine.ext import webapp
23 | from google.appengine.ext.webapp import util
24 |
25 |
26 | application = webapp.WSGIApplication(
27 | [('/', webapp.RedirectHandler.new_factory('/protorpc/form'))],
28 | debug=True)
29 |
30 |
31 | def main():
32 | util.run_wsgi_app(application)
33 |
34 |
35 | if __name__ == '__main__':
36 | main()
37 |
--------------------------------------------------------------------------------
/demos/hello/server/README:
--------------------------------------------------------------------------------
1 | Hello Service
2 | =============
3 |
4 | This is a simple service which asks for a name in the request and
5 | responds with a hello.
6 |
7 | Google App Engine
8 | =================
9 |
10 | For more information about Google App Engine, and to download the SDK, see:
11 |
12 | http://code.google.com/appengine
13 |
14 | Running locally
15 | ===============
16 |
17 | ProtoRPC is packaged with the App Engine SDK, but the version shipped
18 | may not be the most current version due to the App Engine release
19 | schedule. If you'd like to use the most current version of ProtoRPC,
20 | you can install it in the hello/server directory.
21 |
22 | For example on a unix-like OS, you could either copy:
23 |
24 | $ cp -r $PROTORPC/python/protorpc $PROTORPC/demos/hello/server
25 |
26 | or symlink the directory:
27 |
28 | $ ln -s $PROTORPC/python/protorpc $PROTORPC/demos/hello/server/protorpc
29 |
30 | To run this demo locally, you need to run an instance of the Google App
31 | Engine dev-appserver. The server defaults on port 8080.
32 |
33 | Example on a unix-like OS:
34 |
35 | $ python $GAE_SDK/dev_appserver.py $PROTORPC/demos/hello/server
36 |
--------------------------------------------------------------------------------
/demos/experimental/wsgi/README:
--------------------------------------------------------------------------------
1 | Experimental WSGI Service
2 | =========================
3 |
4 | Simple Demo for testing experimental WSGI Code.
5 |
6 | Google App Engine
7 | =================
8 |
9 | For more information about Google App Engine, and to download the SDK, see:
10 |
11 | http://code.google.com/appengine
12 |
13 | Running locally
14 | ===============
15 |
16 | ProtoRPC is packaged with the App Engine SDK, but the version shipped
17 | may not be the most current version due to the App Engine release
18 | schedule. If you'd like to use the most current version of ProtoRPC,
19 | you can install it in the experimental/wsgi directory.
20 |
21 | For example on a unix-like OS, you could either copy:
22 |
23 | $ cp -r $PROTORPC/python/protorpc $PROTORPC/demos/experimental/wsgi
24 |
25 | or symlink the directory:
26 |
27 | $ ln -s $PROTORPC/python/protorpc $PROTORPC/demos/experimental/wsgi/protorpc
28 |
29 | To run this demo locally, you need to run an instance of the Google App
30 | Engine dev-appserver. The server defaults on port 8080.
31 |
32 | Example on a unix-like OS:
33 |
34 | $ python $GAE_SDK/dev_appserver.py $PROTORPC/demos/experimental/wsgi
35 |
--------------------------------------------------------------------------------
/demos/echo/README:
--------------------------------------------------------------------------------
1 | Echo Service
2 | ============
3 |
4 | The echo service is a service that echos a request back to the caller. Useful
5 | for testing and illustrates all data types in the forms interface.
6 |
7 | Google App Engine
8 | =================
9 |
10 | For more information about Google App Engine, and to download the SDK, see:
11 |
12 | http://code.google.com/appengine
13 |
14 | Running locally
15 | ===============
16 |
17 | ProtoRPC is packaged with the App Engine SDK, but the version shipped
18 | may not be the most current version due to the App Engine release
19 | schedule. If you'd like to use the most current version of ProtoRPC,
20 | you can install it in the echo directory.
21 |
22 | For example on a unix-like OS, you could either copy:
23 |
24 | $ cp -r $PROTORPC/python/protorpc $PROTORPC/demos/echo
25 |
26 | or symlink the directory:
27 |
28 | $ ln -s $PROTORPC/python/protorpc $PROTORPC/demos/echo/protorpc
29 |
30 | To run this demo locally, you need to run an instance of the Google App
31 | Engine dev-appserver. The server defaults on port 8080.
32 |
33 | Example on a unix-like OS:
34 |
35 | $ python $GAE_SDK/dev_appserver.py $PROTORPC/demos/echo
36 |
--------------------------------------------------------------------------------
/demos/tunes_db/client/album.html:
--------------------------------------------------------------------------------
1 |
16 |
17 | {% extends "base.html" %}
18 |
19 | {% block title %}Album - {{album.name}}{% endblock %}
20 |
21 | {% block body %}
22 |
23 |
30 |
31 | {% endblock %}
32 |
--------------------------------------------------------------------------------
/demos/tunes_db/server/app.yaml:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | application: tunes-db
19 | version: 1
20 | api_version: 1
21 | runtime: python
22 |
23 | handlers:
24 |
25 | - url: /forms/(.*)\.(png|css|js)
26 | static_files: forms_static/\1.\2
27 | upload: forms_static/(.*)\.(png|css|js)
28 |
29 | - url: /music.*
30 | script: services.py
31 |
32 | - url: /protorpc.*
33 | script: services.py
34 |
35 | - url: /_ah/stats/service.*
36 | script: protorpc_appstats/main.py
37 |
38 | - url: /_ah/stats.*
39 | script: $PYTHON_LIB/google/appengine/ext/appstats/ui.py
40 |
41 | - url: /
42 | script: main.py
43 |
--------------------------------------------------------------------------------
/protorpc/static/methods.html:
--------------------------------------------------------------------------------
1 |
16 |
17 | {% extends 'base.html' %}
18 |
19 | {% block title %}Form for {{service_path|escape}}.{{method_name|escape}}{% endblock %}
20 |
21 | {% block top %}
22 | << Back to method selection
23 |
Form for {{service_path|escape}}.{{method_name|escape}}
31 |
32 |
33 | {% endblock %}
34 |
35 | {% block call %}
36 | loadServices(createForm);
37 | {% endblock %}
38 |
--------------------------------------------------------------------------------
/protorpc/experimental/parser/pyprotobuf.g:
--------------------------------------------------------------------------------
1 | /* !/usr/bin/env python
2 | *
3 | * Copyright 2011 Google Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | grammar pyprotobuf;
19 |
20 | options {
21 | // language=Python;
22 | output = AST;
23 | ASTLabelType = CommonTree;
24 | }
25 |
26 | import protobuf_lexer, protobuf;
27 |
28 | // For reasons I do not understand the HIDDEN elements from the imported
29 | // with their channel intact.
30 |
31 | COMMENT
32 | : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
33 | | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
34 | ;
35 |
36 | WS : ( ' '
37 | | '\t'
38 | | '\r'
39 | | '\n'
40 | ) {$channel=HIDDEN;}
41 | ;
42 |
43 | py_proto_file
44 | : proto_file EOF^
45 | ;
46 |
--------------------------------------------------------------------------------
/demos/hello/server/services.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | import appengine_config
19 |
20 | from protorpc import messages
21 | from protorpc import remote
22 | from protorpc.webapp import service_handlers
23 |
24 |
25 | class HelloRequest(messages.Message):
26 |
27 | my_name = messages.StringField(1, required=True)
28 |
29 |
30 | class HelloResponse(messages.Message):
31 |
32 | hello = messages.StringField(1, required=True)
33 |
34 |
35 | class HelloService(remote.Service):
36 |
37 | @remote.method(HelloRequest, HelloResponse)
38 | def hello(self, request):
39 | return HelloResponse(hello='Hello there, %s!' % request.my_name)
40 |
41 |
42 | def main():
43 | service_handlers.run_services([('/hello', HelloService)])
44 |
45 |
46 | if __name__ == '__main__':
47 | main()
48 |
--------------------------------------------------------------------------------
/demos/tunes_db/client/artist.html:
--------------------------------------------------------------------------------
1 |
16 |
17 | {% extends "album_search.html" %}
18 |
19 | {% block title %}Artist - {{artist.name}}{% endblock %}
20 |
21 | {% block top %}
22 |
23 |
28 |
29 | {% endblock %}
30 |
31 |
32 | {% block bottom %}
33 |
34 |
40 |
41 | {% endblock %}
42 |
--------------------------------------------------------------------------------
/demos/tunes_db/server/services.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | """Web services demo.
19 |
20 | Implements a simple music database. The music database is served
21 | off the /music URL. It supports all built in protocols (url-encoded
22 | and protocol buffers) using the default RPC mapping scheme.
23 |
24 | For details about the Tunes service itself, please see tunes_db.py.
25 |
26 | For details about the datastore representation of the Tunes db, please
27 | see model.py.
28 | """
29 |
30 | __author__ = 'rafek@google.com (Rafe Kaplan)'
31 |
32 | import appengine_config
33 |
34 | from protorpc.webapp import service_handlers
35 |
36 | import tunes_db
37 |
38 |
39 | def main():
40 | service_handlers.run_services(
41 | [('/music', tunes_db.MusicLibraryService),
42 | ])
43 |
44 |
45 | if __name__ == '__main__':
46 | main()
47 |
--------------------------------------------------------------------------------
/demos/tunes_db/server/index.yaml:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2010 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | indexes:
19 |
20 | - kind: Info
21 | properties:
22 | - name: class
23 | - name: encoded_name
24 |
25 | - kind: Info
26 | properties:
27 | - name: artist
28 | - name: class
29 | - name: encoded_name
30 | - name: name
31 |
32 | - kind: Info
33 | properties:
34 | - name: class
35 | - name: encoded_name
36 | - name: name
37 |
38 | # AUTOGENERATED
39 |
40 | # This index.yaml is automatically updated whenever the dev_appserver
41 | # detects that a new type of query is run. If you want to manage the
42 | # index.yaml file manually, remove the above marker line (the line
43 | # saying "# AUTOGENERATED"). If you want to manage some indexes
44 | # manually, move them above the marker line. The index.yaml file is
45 | # automatically uploaded to the admin console when you next deploy
46 | # your application using appcfg.py.
47 |
--------------------------------------------------------------------------------
/experimental/javascript/closure/debug/error.js:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Closure Library Authors. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS-IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | /**
16 | * @fileoverview Provides a base class for custom Error objects such that the
17 | * stack is correctly maintained.
18 | *
19 | * You should never need to throw goog.debug.Error(msg) directly, Error(msg) is
20 | * sufficient.
21 | *
22 | */
23 |
24 | goog.provide('goog.debug.Error');
25 |
26 |
27 |
28 | /**
29 | * Base class for custom error objects.
30 | * @param {*=} opt_msg The message associated with the error.
31 | * @constructor
32 | * @extends {Error}
33 | */
34 | goog.debug.Error = function(opt_msg) {
35 |
36 | // Ensure there is a stack trace.
37 | this.stack = new Error().stack || '';
38 |
39 | if (opt_msg) {
40 | this.message = String(opt_msg);
41 | }
42 | };
43 | goog.inherits(goog.debug.Error, Error);
44 |
45 |
46 | /** @inheritDoc */
47 | goog.debug.Error.prototype.name = 'CustomError';
48 |
--------------------------------------------------------------------------------
/demos/guestbook/README:
--------------------------------------------------------------------------------
1 | Guestbook Service
2 | =================
3 |
4 | This sample contains two sample ProtoRPC services that allow users to
5 | sign a guestbook. The two applications act as client and server.
6 |
7 | Google App Engine
8 | =================
9 |
10 | For more information about Google App Engine, and to download the SDK, see:
11 |
12 | http://code.google.com/appengine
13 |
14 | Running locally
15 | ===============
16 |
17 | ProtoRPC is packaged with the App Engine SDK, but the version shipped
18 | may not be the most current version due to the App Engine release
19 | schedule. If you'd like to use the most current version of ProtoRPC,
20 | you can install it in the guestbook/client and guestbook/server
21 | directories.
22 |
23 | For example on a unix-like OS, you could either copy:
24 |
25 | $ cp -r $PROTORPC/python/protorpc $PROTORPC/demos/guestbook/client
26 | $ cp -r $PROTORPC/python/protorpc $PROTORPC/demos/guestbook/server
27 |
28 | or symlink the directory:
29 |
30 | $ ln -s $PROTORPC/python/protorpc $PROTORPC/demos/guestbook/client/protorpc
31 | $ ln -s $PROTORPC/python/protorpc $PROTORPC/demos/guestbook/server/protorpc
32 |
33 | To run this demo locally, you need to run an instance of the Google App
34 | Engine dev-appserver both for the client and the server. The dev-appserver
35 | defaults on port 8080, so use different ports to avoid a port collision.
36 |
37 | Example on a unix-like OS:
38 |
39 | $ python $GAE_SDK/dev_appserver.py --port=8080 $PROTORPC/demos/guestbook/client &
40 | $ python $GAE_SDK/dev_appserver.py --port=8081 $PROTORPC/demos/guestbook/server
41 |
--------------------------------------------------------------------------------
/demos/guestbook/client/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2011 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | import appengine_config
19 |
20 | import os
21 |
22 | from google.appengine.ext import webapp
23 | from google.appengine.ext.webapp import util
24 |
25 | from protorpc import transport
26 | from protorpc import protojson
27 |
28 | import guestbook
29 |
30 |
31 | postservice = guestbook.PostService.Stub(
32 | transport.HttpTransport('http://postservice-demo.appspot.com/postservice'))
33 |
34 |
35 | class MainHandler(webapp.RequestHandler):
36 | def get(self):
37 | notes = postservice.get_notes(limit=10)
38 | self.response.out.write('Last %d posts...' % len(notes.notes))
39 | for note in notes.notes:
40 | self.response.out.write('