app/main.py
author Lennard de Rijk <ljvderijk@gmail.com>
Thu, 02 Jul 2009 15:40:37 +0200
changeset 2488 69ce84f4c1da
parent 2357 f7b0c04e1e81
permissions -rw-r--r--
Set required is True for StudentProject reference in ProjectSurveyRecord.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
2066
1855c783934f Add missing docstrings to main.py and settings.py.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1015
diff changeset
    17
"""Main Melange module with profiling support.
1855c783934f Add missing docstrings to main.py and settings.py.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1015
diff changeset
    18
"""
1855c783934f Add missing docstrings to main.py and settings.py.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1015
diff changeset
    19
31
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
__authors__ = [
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
  # alphabetical order by last name, please
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
  '"Augie Fackler" <durin42@gmail.com>',
2357
f7b0c04e1e81 Remove unused imports from main.py.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2336
diff changeset
    23
  '"Pawel Solyga" <pawel.solyga@gmail.com>',
31
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
  ]
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
import logging
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
from google.appengine.ext.webapp import util
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
2357
f7b0c04e1e81 Remove unused imports from main.py.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2336
diff changeset
    31
# pylint: disable-msg=W0611
2335
366e64ecba91 Add web based python shell to Melange.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2066
diff changeset
    32
import gae_django
31
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
1015
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    35
def profile_main_as_html():
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    36
  """Main program for profiling. Profiling data added as HTML to the page.
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    37
  """
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    38
  import cProfile
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    39
  import pstats
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    40
  import StringIO
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    41
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    42
  prof = cProfile.Profile()
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    43
  prof = prof.runctx('real_main()', globals(), locals())
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    44
  stream = StringIO.StringIO()
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    45
  stats = pstats.Stats(prof, stream=stream)
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    46
  # stats.strip_dirs()  # Don't; too many modules are named __init__.py.
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    47
  
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    48
  # 'time', 'cumulative' or 'calls'
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    49
  stats.sort_stats('time')  
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    50
  
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    51
  # Optional arg: how many to print
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    52
  stats.print_stats() 
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    53
  # The rest is optional.
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    54
  # stats.print_callees()
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    55
  # stats.print_callers()
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    56
  print '\n<hr>'
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    57
  print '<h1>Profile data</h1>'
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    58
  print '<pre>'
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    59
  print stream.getvalue()[:1000000]
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    60
  print '</pre>'
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    61
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    62
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    63
def profile_main_as_logs():
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    64
  """Main program for profiling. Profiling data logged.
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    65
  """
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    66
  import cProfile
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    67
  import pstats
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    68
  import StringIO
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    69
  
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    70
  prof = cProfile.Profile()
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    71
  prof = prof.runctx("real_main()", globals(), locals())
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    72
  stream = StringIO.StringIO()
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    73
  stats = pstats.Stats(prof, stream=stream)
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    74
  stats.sort_stats('time')  # Or cumulative
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    75
  stats.print_stats(80)  # 80 = how many to print
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    76
  # The rest is optional.
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    77
  # stats.print_callees()
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    78
  # stats.print_callers()
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    79
  logging.info("Profile data:\n%s", stream.getvalue())
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    80
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    81
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    82
def real_main():
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    83
  """Main program without profiling.
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    84
  """
2335
366e64ecba91 Add web based python shell to Melange.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2066
diff changeset
    85
  import django.core.handlers.wsgi
684
896672e44e03 Fix for randomely ocurring bug
Sverre Rabbelier <srabbelier@gmail.com>
parents: 324
diff changeset
    86
31
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    87
  # Create a Django application for WSGI.
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    88
  application = django.core.handlers.wsgi.WSGIHandler()
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    89
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 2066
diff changeset
    90
  from soc.modules import callback
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 2066
diff changeset
    91
  from soc.modules import core
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 2066
diff changeset
    92
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 2066
diff changeset
    93
  callback.registerCore(core.Core())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 2066
diff changeset
    94
  callback.getCore().registerModuleCallbacks()
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 2066
diff changeset
    95
31
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    96
  # Run the WSGI CGI handler with that application.
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    97
  util.run_wsgi_app(application)
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
1015
b9d51be5104a Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 684
diff changeset
    99
main = real_main
31
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   100
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   101
if __name__ == '__main__':
8b43c541afa7 First iteration of a "prototype" Melange app, along with an initial Person
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   102
  main()