Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.930
diff -u -p -r1.930 common.inc
--- includes/common.inc	4 Jul 2009 18:26:42 -0000	1.930
+++ includes/common.inc	6 Jul 2009 14:19:36 -0000
@@ -3792,8 +3792,8 @@ function drupal_render(&$elements) {
   }
 
   // Let the theme function in #theme_wrapper add markup around the rendered
-  // children.
-  if (!empty($elements['#theme_wrapper'])) {
+  // children. But don't render an empty region wrapper.
+  if (!empty($elements['#theme_wrapper']) && (empty($elements['#region']) || $elements['#children'])) {
     $elements['#children'] = theme($elements['#theme_wrapper'], $elements);
   }
 
@@ -4059,6 +4059,10 @@ function drupal_common_theme() {
     'install_page' => array(
       'arguments' => array('content' => NULL),
     ),
+    'region' => array(
+      'arguments' => array('elements' => NULL),
+      'template' => 'region',
+    ),
     'task_list' => array(
       'arguments' => array('items' => NULL, 'active' => NULL),
     ),
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.497
diff -u -p -r1.497 theme.inc
--- includes/theme.inc	2 Jul 2009 04:27:22 -0000	1.497
+++ includes/theme.inc	6 Jul 2009 14:19:37 -0000
@@ -2054,3 +2054,25 @@ function template_page_suggestions($args
 
   return $suggestions;
 }
+
+/**
+ * Preprocess variables for region.tpl.php
+ *
+ * Prepare the values passed to the theme_region function to be passed into a
+ * pluggable template engine. Uses the region name to generate a template file
+ * suggestions. If none are found, the default region.tpl.php is used.
+ *
+ * @see region.tpl.php
+ */
+function template_preprocess_region(&$variables) {
+  // Create the $content variable that templates expect.
+  $variables['blocks'] = $variables['elements']['#children'];
+  $variables['region'] = $variables['elements']['#region'];
+
+  $variables['classes_array'][] = str_replace('_', '-', 'region-' . $variables['region']);
+  if ($variables['region'] == 'page_top') {
+    $variables['classes_array'][] = 'clearfix';
+  }
+
+  $variables['template_files'][] = 'region-' . str_replace('_', '-', $variables['region']);
+}
Index: modules/system/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/page.tpl.php,v
retrieving revision 1.24
diff -u -p -r1.24 page.tpl.php
--- modules/system/page.tpl.php	4 Jul 2009 05:21:15 -0000	1.24
+++ modules/system/page.tpl.php	6 Jul 2009 14:19:37 -0000
@@ -104,11 +104,8 @@
 </head>
 <body class="<?php print $classes; ?>">
 
-  <?php if ($page_top): ?>
-    <div id="page-top-region" class="clearfix">
-      <?php print $page_top; ?>
-    </div>
-  <?php endif; ?>
+  <?php print $page_top; ?>
+
   <div id="page-wrapper"><div id="page">
 
     <div id="header"><div class="section clearfix">
@@ -143,11 +140,7 @@
         <div id="search-box"><?php print $search_box; ?></div>
       <?php endif; ?>
 
-      <?php if ($header): ?>
-        <div id="header-region" class="region">
-          <?php print $header; ?>
-        </div>
-      <?php endif; ?>
+      <?php print $header; ?>
 
     </div></div> <!-- /.section, /#header -->
 
@@ -170,20 +163,18 @@
         <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
         <?php if ($tabs): ?><div class="tabs"><?php print $tabs; ?></div><?php endif; ?>
         <?php print $help; ?>
-        <div id="content-area" class="region">
-          <?php print $content; ?>
-        </div> <!-- /#content-area -->
+        <?php print $content; ?>
         <?php print $feed_icons; ?>
       </div></div> <!-- /.section, /#content -->
 
       <?php if ($left): ?>
-        <div id="sidebar-left" class="column sidebar"><div class="section region">
+        <div id="sidebar-left" class="column sidebar"><div class="section">
           <?php print $left; ?>
         </div></div> <!-- /.section, /#sidebar-left -->
       <?php endif; ?>
 
       <?php if ($right): ?>
-        <div id="sidebar-right" class="column sidebar"><div class="section region">
+        <div id="sidebar-right" class="column sidebar"><div class="section">
           <?php print $right; ?>
         </div></div> <!-- /.section, /#sidebar-right -->
       <?php endif; ?>
@@ -192,7 +183,7 @@
 
     <div id="footer"><div class="section">
       <?php print theme('links', $secondary_menu, array('id' => 'secondary-menu', 'class' => 'links clearfix')); ?>
-      <?php if ($footer): ?><div id="footer-region" class="region"><?php print $footer; ?></div><?php endif; ?>
+      <?php print $footer; ?>
     </div></div> <!-- /.section, /#footer -->
 
   </div></div> <!-- /#page, /#page-wrapper -->
Index: modules/system/region.tpl.php
===================================================================
RCS file: modules/system/region.tpl.php
diff -N modules/system/region.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/system/region.tpl.php	6 Jul 2009 14:19:37 -0000
@@ -0,0 +1,32 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Default theme implementation to display a region.
+ *
+ * Available variables:
+ * - $blocks: The blocks for this region.
+ * - $classes: String of classes that can be used to style contextually through
+ *   CSS. It can be manipulated through the variable $classes_array from
+ *   preprocess functions. The default values can be one or more of the following:
+ *   - region: The current template type, i.e., "theming hook".
+ *   - region-[name]: The name of the region with underscores replaced with
+ *     dashes. For example, the page_top region would have a region-page-top class.
+ * - $region: The name of the region variable as defined in the theme's .info file.
+ *
+ * Helper variables:
+ * - $classes_array: Array of html class attribute values. It is flattened
+ *   into a string within the variable $classes.
+ * - $is_admin: Flags true when the current user is an administrator.
+ * - $is_front: Flags true when presented in the front page.
+ * - $logged_in: Flags true when the current user is a logged-in member.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_region()
+ * @see template_process()
+ */
+?>
+<div class="<?php print $classes; ?>">
+  <?php print $blocks ?>
+</div>
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.722
diff -u -p -r1.722 system.module
--- modules/system/system.module	5 Jul 2009 18:00:10 -0000	1.722
+++ modules/system/system.module	6 Jul 2009 14:19:37 -0000
@@ -1334,6 +1334,28 @@ function system_init() {
   }
 }
 
+/**
+ * Implement hook_page_alter().
+ *
+ * Render regions.
+ */
+function system_page_alter($page) {
+  global $theme;
+
+  // Populate all block regions
+  $regions = system_region_list($theme);
+
+  // Load all region content assigned via blocks.
+  foreach (array_keys($regions) as $region) {
+    // Prevent left and right regions from rendering blocks when 'show_blocks' == FALSE.
+    if (!empty($page[$region])) {
+      $page[$region] += array(
+        '#theme_wrapper' => 'region',
+        '#region' => $region,
+      );
+    }
+  }
+}
 
 /**
  * Implement MODULE_preprocess_HOOK().
