Skip to content
This repository

Django sample #123

Merged
merged 3 commits into from about 2 years ago

2 participants

sir-brizz Burak Arslan
sir-brizz

Here is the Django sample that was requested using rpclib/master branch and Django 1.3.1

Burak Arslan plq merged commit a3b14df into from March 03, 2012
Burak Arslan plq closed this March 03, 2012
Burak Arslan
Owner
plq commented March 03, 2012

thanks! sorry for the delay, i'm away from home.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
29  examples/django/rpctest/__init__.py
... ...
@@ -0,0 +1,29 @@
  1
+#!/usr/bin/env python
  2
+# encoding: utf8
  3
+#
  4
+# Copyright © BJ Cardon <bj dot car dot don at gmail dot com>,
  5
+# All rights reserved.
  6
+#
  7
+# Redistribution and use in source and binary forms, with or without
  8
+# modification, are permitted provided that the following conditions are met:
  9
+#
  10
+#    1. Redistributions of source code must retain the above copyright notice,
  11
+#       this list of conditions and the following disclaimer.
  12
+#    2. Redistributions in binary form must reproduce the above copyright
  13
+#       notice, this list of conditions and the following disclaimer in the
  14
+#       documentation and/or other materials provided with the distribution.
  15
+#    3. Neither the name of the owner nor the names of its contributors may be
  16
+#       used to endorse or promote products derived from this software without
  17
+#       specific prior written permission.
  18
+#
  19
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT,
  23
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  26
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  28
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29
+#
0  examples/django/rpctest/core/__init__.py
No changes.
53  examples/django/rpctest/core/views.py
... ...
@@ -0,0 +1,53 @@
  1
+#!/usr/bin/env python
  2
+# encoding: utf8
  3
+#
  4
+# Copyright © BJ Cardon <bj dot car dot don at gmail dot com>,
  5
+# All rights reserved.
  6
+#
  7
+# Redistribution and use in source and binary forms, with or without
  8
+# modification, are permitted provided that the following conditions are met:
  9
+#
  10
+#    1. Redistributions of source code must retain the above copyright notice,
  11
+#       this list of conditions and the following disclaimer.
  12
+#    2. Redistributions in binary form must reproduce the above copyright
  13
+#       notice, this list of conditions and the following disclaimer in the
  14
+#       documentation and/or other materials provided with the distribution.
  15
+#    3. Neither the name of the owner nor the names of its contributors may be
  16
+#       used to endorse or promote products derived from this software without
  17
+#       specific prior written permission.
  18
+#
  19
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT,
  23
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  26
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  28
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29
+#
  30
+
  31
+from rpclib.server.django import DjangoApplication
  32
+from rpclib.model.primitive import String, Integer
  33
+from rpclib.model.complex import Iterable
  34
+from rpclib.service import ServiceBase
  35
+from rpclib.interface.wsdl import Wsdl11
  36
+from rpclib.protocol.soap import Soap11
  37
+from rpclib.application import Application
  38
+from rpclib.decorator import rpc
  39
+from django.views.decorators.csrf import csrf_exempt
  40
+
  41
+@csrf_exempt
  42
+class HelloWorldService(ServiceBase):
  43
+    @rpc(String, Integer, _returns=Iterable(String))
  44
+    def say_hello(ctx, name, times):
  45
+        for i in xrange(times):
  46
+            yield 'Hello, %s' % name
  47
+
  48
+hello_world_service = DjangoApplication(Application([HelloWorldService],
  49
+        'localhost.tns',
  50
+        interface=Wsdl11(),
  51
+        in_protocol=Soap11(),
  52
+        out_protocol=Soap11()
  53
+    ))
43  examples/django/rpctest/manage.py
... ...
@@ -0,0 +1,43 @@
  1
+#!/usr/bin/env python
  2
+# encoding: utf8
  3
+#
  4
+# Copyright © BJ Cardon <bj dot car dot don at gmail dot com>,
  5
+# All rights reserved.
  6
+#
  7
+# Redistribution and use in source and binary forms, with or without
  8
+# modification, are permitted provided that the following conditions are met:
  9
+#
  10
+#    1. Redistributions of source code must retain the above copyright notice,
  11
+#       this list of conditions and the following disclaimer.
  12
+#    2. Redistributions in binary form must reproduce the above copyright
  13
+#       notice, this list of conditions and the following disclaimer in the
  14
+#       documentation and/or other materials provided with the distribution.
  15
+#    3. Neither the name of the owner nor the names of its contributors may be
  16
+#       used to endorse or promote products derived from this software without
  17
+#       specific prior written permission.
  18
+#
  19
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT,
  23
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  26
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  28
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29
+#
  30
+
  31
+from django.core.management import execute_manager
  32
+import imp
  33
+try:
  34
+    imp.find_module('settings') # Assumed to be in the same directory.
  35
+except ImportError:
  36
+    import sys
  37
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
  38
+    sys.exit(1)
  39
+
  40
+import settings
  41
+
  42
+if __name__ == "__main__":
  43
+    execute_manager(settings)
175  examples/django/rpctest/settings.py
... ...
@@ -0,0 +1,175 @@
  1
+#!/usr/bin/env python
  2
+# encoding: utf8
  3
+#
  4
+# Copyright © BJ Cardon <bj dot car dot don at gmail dot com>,
  5
+# All rights reserved.
  6
+#
  7
+# Redistribution and use in source and binary forms, with or without
  8
+# modification, are permitted provided that the following conditions are met:
  9
+#
  10
+#    1. Redistributions of source code must retain the above copyright notice,
  11
+#       this list of conditions and the following disclaimer.
  12
+#    2. Redistributions in binary form must reproduce the above copyright
  13
+#       notice, this list of conditions and the following disclaimer in the
  14
+#       documentation and/or other materials provided with the distribution.
  15
+#    3. Neither the name of the owner nor the names of its contributors may be
  16
+#       used to endorse or promote products derived from this software without
  17
+#       specific prior written permission.
  18
+#
  19
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT,
  23
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  26
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  28
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29
+#
  30
+
  31
+# Django settings for rpctest project.
  32
+DEBUG = True
  33
+TEMPLATE_DEBUG = DEBUG
  34
+
  35
+ADMINS = (
  36
+    # ('Your Name', 'your_email@example.com'),
  37
+)
  38
+
  39
+MANAGERS = ADMINS
  40
+
  41
+DATABASES = {
  42
+    'default': {
  43
+        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
  44
+        'NAME': '',                      # Or path to database file if using sqlite3.
  45
+        'USER': '',                      # Not used with sqlite3.
  46
+        'PASSWORD': '',                  # Not used with sqlite3.
  47
+        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
  48
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
  49
+    }
  50
+}
  51
+
  52
+# Local time zone for this installation. Choices can be found here:
  53
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  54
+# although not all choices may be available on all operating systems.
  55
+# On Unix systems, a value of None will cause Django to use the same
  56
+# timezone as the operating system.
  57
+# If running in a Windows environment this must be set to the same as your
  58
+# system time zone.
  59
+TIME_ZONE = 'America/Chicago'
  60
+
  61
+# Language code for this installation. All choices can be found here:
  62
+# http://www.i18nguy.com/unicode/language-identifiers.html
  63
+LANGUAGE_CODE = 'en-us'
  64
+
  65
+SITE_ID = 1
  66
+
  67
+# If you set this to False, Django will make some optimizations so as not
  68
+# to load the internationalization machinery.
  69
+USE_I18N = True
  70
+
  71
+# If you set this to False, Django will not format dates, numbers and
  72
+# calendars according to the current locale
  73
+USE_L10N = True
  74
+
  75
+# Absolute filesystem path to the directory that will hold user-uploaded files.
  76
+# Example: "/home/media/media.lawrence.com/media/"
  77
+MEDIA_ROOT = ''
  78
+
  79
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
  80
+# trailing slash.
  81
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
  82
+MEDIA_URL = ''
  83
+
  84
+# Absolute path to the directory static files should be collected to.
  85
+# Don't put anything in this directory yourself; store your static files
  86
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
  87
+# Example: "/home/media/media.lawrence.com/static/"
  88
+STATIC_ROOT = ''
  89
+
  90
+# URL prefix for static files.
  91
+# Example: "http://media.lawrence.com/static/"
  92
+STATIC_URL = '/static/'
  93
+
  94
+# URL prefix for admin static files -- CSS, JavaScript and images.
  95
+# Make sure to use a trailing slash.
  96
+# Examples: "http://foo.com/static/admin/", "/static/admin/".
  97
+ADMIN_MEDIA_PREFIX = '/static/admin/'
  98
+
  99
+# Additional locations of static files
  100
+STATICFILES_DIRS = (
  101
+    # Put strings here, like "/home/html/static" or "C:/www/django/static".
  102
+    # Always use forward slashes, even on Windows.
  103
+    # Don't forget to use absolute paths, not relative paths.
  104
+)
  105
+
  106
+# List of finder classes that know how to find static files in
  107
+# various locations.
  108
+STATICFILES_FINDERS = (
  109
+    'django.contrib.staticfiles.finders.FileSystemFinder',
  110
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  111
+#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
  112
+)
  113
+
  114
+# Make this unique, and don't share it with anybody.
  115
+SECRET_KEY = '#pa7-0yh+(9a)p(_r$3&^j5&5f3sal-m_8+r*k-_ft@4#)la(6'
  116
+
  117
+# List of callables that know how to import templates from various sources.
  118
+TEMPLATE_LOADERS = (
  119
+    'django.template.loaders.filesystem.Loader',
  120
+    'django.template.loaders.app_directories.Loader',
  121
+#     'django.template.loaders.eggs.Loader',
  122
+)
  123
+
  124
+MIDDLEWARE_CLASSES = (
  125
+    'django.middleware.common.CommonMiddleware',
  126
+    'django.contrib.sessions.middleware.SessionMiddleware',
  127
+    'django.middleware.csrf.CsrfViewMiddleware',
  128
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
  129
+    'django.contrib.messages.middleware.MessageMiddleware',
  130
+)
  131
+
  132
+ROOT_URLCONF = 'rpctest.urls'
  133
+
  134
+TEMPLATE_DIRS = (
  135
+    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
  136
+    # Always use forward slashes, even on Windows.
  137
+    # Don't forget to use absolute paths, not relative paths.
  138
+)
  139
+
  140
+INSTALLED_APPS = (
  141
+    'django.contrib.auth',
  142
+    'django.contrib.contenttypes',
  143
+    'django.contrib.sessions',
  144
+    'django.contrib.sites',
  145
+    'django.contrib.messages',
  146
+    'django.contrib.staticfiles',
  147
+    'core',
  148
+    # Uncomment the next line to enable the admin:
  149
+    # 'django.contrib.admin',
  150
+    # Uncomment the next line to enable admin documentation:
  151
+    # 'django.contrib.admindocs',
  152
+)
  153
+
  154
+# A sample logging configuration. The only tangible logging
  155
+# performed by this configuration is to send an email to
  156
+# the site admins on every HTTP 500 error.
  157
+# See http://docs.djangoproject.com/en/dev/topics/logging for
  158
+# more details on how to customize your logging configuration.
  159
+LOGGING = {
  160
+    'version': 1,
  161
+    'disable_existing_loggers': False,
  162
+    'handlers': {
  163
+        'mail_admins': {
  164
+            'level': 'ERROR',
  165
+            'class': 'django.utils.log.AdminEmailHandler'
  166
+        }
  167
+    },
  168
+    'loggers': {
  169
+        'django.request': {
  170
+            'handlers': ['mail_admins'],
  171
+            'level': 'ERROR',
  172
+            'propagate': True,
  173
+        },
  174
+    }
  175
+}
35  examples/django/rpctest/urls.py
... ...
@@ -0,0 +1,35 @@
  1
+#!/usr/bin/env python
  2
+# encoding: utf8
  3
+#
  4
+# Copyright © BJ Cardon <bj dot car dot don at gmail dot com>,
  5
+# All rights reserved.
  6
+#
  7
+# Redistribution and use in source and binary forms, with or without
  8
+# modification, are permitted provided that the following conditions are met:
  9
+#
  10
+#    1. Redistributions of source code must retain the above copyright notice,
  11
+#       this list of conditions and the following disclaimer.
  12
+#    2. Redistributions in binary form must reproduce the above copyright
  13
+#       notice, this list of conditions and the following disclaimer in the
  14
+#       documentation and/or other materials provided with the distribution.
  15
+#    3. Neither the name of the owner nor the names of its contributors may be
  16
+#       used to endorse or promote products derived from this software without
  17
+#       specific prior written permission.
  18
+#
  19
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT,
  23
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  26
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  28
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29
+#
  30
+
  31
+from django.conf.urls.defaults import patterns, include, url
  32
+
  33
+urlpatterns = patterns('',
  34
+    url(r'^hello_world/','core.views.hello_world_service'),
  35
+)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.