update the "Minimal Layout" and create the "Complete layout"

RESOLVED WONTFIX

Status

Cloud Services
Server: Core
RESOLVED WONTFIX
7 years ago
7 years ago

People

(Reporter: tarek, Assigned: rtilder)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

7 years ago
Right now we have one template to create apps, in MoPy called "Minimal Layout"

see http://docs.services.mozilla.com/server-devguide/code.html

We need to update it with the latest goodies we've added lately + implement the "Complete Layout"
Assignee: nobody → rtilder
Blocks: 676423
(Assignee)

Comment 2

7 years ago
Created attachment 552560 [details] [diff] [review]
First draft of the update-Minimal-Layout portion

Just first draft of the update portion of the bug.  I'm sure there's stuff you have in mind that's missing, Tarek.
Attachment #552560 - Flags: review?(tarek)
(Assignee)

Comment 3

7 years ago
Created attachment 552654 [details] [diff] [review]
First draft of the "Complete Layout" portion
Attachment #552654 - Flags: feedback?(telliott)
Attachment #552654 - Flags: feedback?(tarek)
Attachment #552654 - Flags: feedback?(rmiller)
(Reporter)

Comment 4

7 years ago
Comment on attachment 552654 [details] [diff] [review]
First draft of the "Complete Layout" portion

...

in __init__ I would put a logger for the app.

  import logging
  logger = logging.getLogger($appname)

>+++ projects/server-devtools/mopytools/apptemplate/services_wsgi/+package+/__init__.py_tmpl	2011-08-04 10:54:33.000000000 -0700


...
>+++ projects/server-devtools/mopytools/apptemplate/services_wsgi/+package+/controller.py_tmpl	2011-08-04 14:19:43.000000000 -0700

>+#
>+# The Initial Developer of the Original Code is the Mozilla Foundation.

nitpick: the year can be templatized

>+# Portions created by the Initial Developer are Copyright (C) 2010
...

>+from services import logger
>+

  
  |

Let's make sure the generated app returns 0 warnings with Flake8. Here there's a missing line

  |
  

>+class ${appname}Controller(object):
>+
>+    def __init__(self, app):
>+        self.app = app
>+
>+    def sample_method(self, request):
>+        pass
>+


...
>diff -ruN -x '.hg*' -x .Python -x '*~' -x '*.orig' code/hg.mozilla.org/server-devtools/mopytools/apptemplate/services_wsgi/+package+/tests/functional/__init__.py_tmpl projects/server-devtools/mopytools/apptemplate/services_wsgi/+package+/tests/functional/__init__.py_tmpl
>--- code/hg.mozilla.org/server-devtools/mopytools/apptemplate/services_wsgi/+package+/tests/functional/__init__.py_tmpl	1969-12-31 16:00:00.000000000 -0800
>+++ projects/server-devtools/mopytools/apptemplate/services_wsgi/+package+/tests/functional/__init__.py_tmpl	2011-08-12 07:20:30.000000000 -0700
>@@ -0,0 +1,52 @@
>+# ***** BEGIN LICENSE BLOCK *****
>+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
>+#
>+# The contents of this file are subject to the Mozilla Public License Version
>+# 1.1 (the "License"); you may not use this file except in compliance with
>+# the License. You may obtain a copy of the License at
>+# http://www.mozilla.org/MPL/
>+#
>+# Software distributed under the License is distributed on an "AS IS" basis,
>+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
>+# for the specific language governing rights and limitations under the
>+# License.
>+#
>+# The Original Code is ${projname|empty}
>+#
>+# The Initial Developer of the Original Code is the Mozilla Foundation.
>+# Portions created by the Initial Developer are Copyright (C) 2010
>+# the Initial Developer. All Rights Reserved.
>+#
>+# Contributor(s):
>+#   ${author|empty} (${author_email|empty})
>+#
>+# Alternatively, the contents of this file may be used under the terms of
>+# either the GNU General Public License Version 2 or later (the "GPL"), or
>+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
>+# in which case the provisions of the GPL or the LGPL are applicable instead
>+# of those above. If you wish to allow use of your version of this file only
>+# under the terms of either the GPL or the LGPL, and not to allow others to
>+# use your version of this file under the terms of the MPL, indicate your
>+# decision by deleting the provisions above and replace them with the notice
>+# and other provisions required by the GPL or the LGPL. If you do not delete
>+# the provisions above, a recipient may use your version of this file under
>+# the terms of any one of the MPL, the GPL or the LGPL.
>+#
>+# ***** END LICENSE BLOCK *****
>+
>+import os
>+import unittest
>+import random
>+
>+from webtest import TestApp
>+
>+from ${appname}.wsgiapp import make_app
>+


This does not bring any value as it is (better have no setUp/tearDown at all)

JR suggested to have a test that breaks here 

>+class TestWsgiApp(unittest.TestCase):
>+
>+    def setUp(self):
>+        pass
>+
>+    def tearDown(self):
>+        pass


...
>+++ projects/server-devtools/mopytools/apptemplate/services_wsgi/+package+/wsgiapp.py_tmpl	2011-08-04 13:29:18.000000000 -0700
...
>+

the _API_ and _USERNAME_ stuff is Sync specific.

Maybe you can have something without those here


>+def _url(url):
>+    for pattern, replacer in (('_API_', '{api:1.0|1}'),
>+                              ('_USERNAME_',
>+                               '{username:[a-zA-Z0-9._-]+}')):
>+        url = url.replace(pattern, replacer)
>+    return url
>+
>+
>+controllers = { '${appname}': ${appname}Controller }
>+

We can remove them since we don't need to implement them

>+    #
>+    # You don't need to implement these methods.  See
>+    # services.baseapp.SyncServerApp for details on methods
>+    #
>+
>+    # Hook to manipulate headers before the request processed
>+    def _before_call(self, request):
>+        return {}
>+
>+    # Debug page
>+    def _debug_server(self, request):
>+        return []
>+
>+    # Heartbeat page
>+    def _check_server(self, request):
>+        pass
>+


Otherwise seems like a good start for that template
Attachment #552654 - Flags: feedback?(tarek) → feedback+
(Reporter)

Comment 5

7 years ago
Comment on attachment 552560 [details] [diff] [review]
First draft of the update-Minimal-Layout portion

those fixes lgtm

you can probably reuse the description in setup.py's metadata
Attachment #552560 - Flags: review?(tarek) → review+
Comment on attachment 552654 [details] [diff] [review]
First draft of the "Complete Layout" portion

Review of attachment 552654 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM
Attachment #552654 - Flags: feedback?(rmiller) → feedback+
Attachment #552654 - Flags: feedback?(telliott) → feedback+
(Reporter)

Comment 7

7 years ago
We've changed plan: we will build templates for Pyramid
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.