PageRenderTime 31ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/events/onrequeststart.cfm

http://cfwheels.googlecode.com/
ColdFusion | 77 lines | 71 code | 6 blank | 0 comment | 16 complexity | 626b119aa062cae76095e9401a2a5083 MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cffunction name="onRequestStart" returntype="void" access="public" output="false">
  2. <cfargument name="targetPage" type="any" required="true">
  3. <cfscript>
  4. // abort if called from incorrect file
  5. $abortInvalidRequest();
  6. // need to setup the wheels struct up here since it's used to store debugging info below if this is a reload request
  7. $initializeRequestScope();
  8. // reload application by calling onApplicationStart if requested
  9. if (StructKeyExists(URL, "reload") && (!StructKeyExists(application, "wheels") || !StructKeyExists(application.wheels, "reloadPassword") || !Len(application.wheels.reloadPassword) || (StructKeyExists(URL, "password") && URL.password == application.wheels.reloadPassword)))
  10. {
  11. $debugPoint("total,reload");
  12. $simpleLock(execute="onApplicationStart", name="wheelsReloadLock", type="exclusive", timeout=180);
  13. }
  14. // run the rest of the request start code
  15. $simpleLock(execute="$runOnRequestStart", executeArgs=arguments, name="wheelsReloadLock", type="readOnly", timeout=180);
  16. </cfscript>
  17. </cffunction>
  18. <cffunction name="$runOnRequestStart" returntype="void" access="public" output="false">
  19. <cfargument name="targetPage" type="any" required="true">
  20. <cfscript>
  21. var loc = {};
  22. if (application.wheels.showDebugInformation)
  23. {
  24. // if the first debug point has not already been set in a reload request we set it here
  25. if (StructKeyExists(request.wheels, "execution"))
  26. $debugPoint("reload");
  27. else
  28. $debugPoint("total");
  29. $debugPoint("requestStart");
  30. request.wheels.deprecation = [];
  31. }
  32. // copy over the cgi variables we need to the request scope unless it's already been done on application start
  33. if (!StructKeyExists(request, "cgi"))
  34. request.cgi = $cgiScope();
  35. // reload the plugins on each request if cachePlugins is set to false
  36. if (!application.wheels.cachePlugins)
  37. $loadPlugins();
  38. // inject methods from plugins directly to Application.cfc
  39. if (!StructIsEmpty(application.wheels.mixins))
  40. $include(template="wheels/plugins/injection.cfm");
  41. if (application.wheels.environment == "maintenance")
  42. {
  43. if (StructKeyExists(URL, "except"))
  44. application.wheels.ipExceptions = URL.except;
  45. if (!Len(application.wheels.ipExceptions) || !ListFind(application.wheels.ipExceptions, request.cgi.remote_addr))
  46. {
  47. $includeAndOutput(template="#application.wheels.eventPath#/onmaintenance.cfm");
  48. $abort();
  49. }
  50. }
  51. if (Right(arguments.targetPage, 4) == ".cfc")
  52. {
  53. StructDelete(this, "onRequest");
  54. StructDelete(variables, "onRequest");
  55. }
  56. if (!application.wheels.cacheModelInitialization)
  57. $simpleLock(name="modelLock", execute="$clearModelInitializationCache", type="exclusive");
  58. if (!application.wheels.cacheControllerInitialization)
  59. $simpleLock(name="controllerLock", execute="$clearControllerInitializationCache", type="exclusive");
  60. if (!application.wheels.cacheRoutes)
  61. $loadRoutes();
  62. $include(template="#application.wheels.eventPath#/onrequeststart.cfm");
  63. if (application.wheels.showDebugInformation)
  64. $debugPoint("requestStart");
  65. </cfscript>
  66. </cffunction>