[Jifty-commit] r950 - in jifty/branches/jifty-jsan: . lib lib/Jifty/Action lib/Jifty/Model

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Apr 27 21:28:38 EDT 2006


Author: trs
Date: Thu Apr 27 21:28:36 2006
New Revision: 950

Added:
   jifty/branches/jifty-jsan/lib/Jifty/DateTime.pm
Modified:
   jifty/branches/jifty-jsan/   (props changed)
   jifty/branches/jifty-jsan/Changelog
   jifty/branches/jifty-jsan/MANIFEST
   jifty/branches/jifty-jsan/Makefile.PL
   jifty/branches/jifty-jsan/lib/Jifty.pm
   jifty/branches/jifty-jsan/lib/Jifty/Action/Record.pm
   jifty/branches/jifty-jsan/lib/Jifty/ClassLoader.pm
   jifty/branches/jifty-jsan/lib/Jifty/Everything.pm
   jifty/branches/jifty-jsan/lib/Jifty/Model/Session.pm

Log:
 r10145 at zot (orig r942):  jesse | 2006-04-27 01:06:38 -0400
  r11966 at hualien:  jesse | 2006-04-27 00:18:41 -0400
  * Added suppport for native support for dates and timestamps with time zones 
  
  NOTE: JIFTY NOW SETS $ENV{TZ'} TO GMT work around a bug in Time::Local
 
 r10146 at zot (orig r943):  jesse | 2006-04-27 01:07:08 -0400
  r11977 at hualien:  jesse | 2006-04-27 01:05:12 -0400
  * A more conservative Time::Local / $ENV{TZ} workaround
 
 r10147 at zot (orig r944):  autrijus | 2006-04-27 01:16:38 -0400
 * ClassLoader: Also create CRUD scaffolding for App::Model::Class::Subclass.
 r10148 at zot (orig r945):  alexmv | 2006-04-27 03:07:58 -0400
  r12663 at zoq-fot-pik:  chmrr | 2006-04-27 03:07:32 -0400
   * Missing semicolon in classloader
 
 r10149 at zot (orig r946):  autrijus | 2006-04-27 03:35:13 -0400
 * update MANIFEST
 r10150 at zot (orig r947):  jesse | 2006-04-27 14:14:52 -0400
  r11999 at hualien:  jesse | 2006-04-27 14:14:37 -0400
  * The stub, it breaks apps.
 
 r10151 at zot (orig r948):  alexmv | 2006-04-27 14:16:19 -0400
  r12669 at zoq-fot-pik:  chmrr | 2006-04-27 14:15:55 -0400
   * refers_to isn't actually a reference, it's a string.
  UNIVERSAL::isa is actually (more) right here.
 
 r10154 at zot (orig r949):  trs | 2006-04-27 19:47:39 -0400
  r10153 at zot:  tom | 2006-04-27 19:47:16 -0400
  Add note about class name breakage
 


Modified: jifty/branches/jifty-jsan/Changelog
==============================================================================
--- jifty/branches/jifty-jsan/Changelog	(original)
+++ jifty/branches/jifty-jsan/Changelog	Thu Apr 27 21:28:36 2006
@@ -1,3 +1,10 @@
+SVN revision r932
+
+  * Form fields no longer automatically insert the field name by itself
+    as a class.  Instead, the class has changed to "argument-<fieldname>"
+	to avoid conflicts with generic class names (such as date).
+
+
 SVN revision r809
 
   * Move allow and deny'ing of actions into Jifty::API; this breaks
@@ -143,4 +150,4 @@
    multi-level package names
 
 
-0.51225 - Initial release
\ No newline at end of file
+0.51225 - Initial release

Modified: jifty/branches/jifty-jsan/MANIFEST
==============================================================================
--- jifty/branches/jifty-jsan/MANIFEST	(original)
+++ jifty/branches/jifty-jsan/MANIFEST	Thu Apr 27 21:28:36 2006
@@ -1,9 +1,12 @@
+AUTHORS
 bin/build_par
 bin/jifty
 bin/service
 bin/xgettext
 Changelog
 doc/ajax-upgraded-links
+doc/building_a_par
+doc/client_side_continuations
 doc/command_naming
 doc/edit-in-place
 doc/packaging
@@ -54,6 +57,7 @@
 lib/Jifty/Config.pm
 lib/Jifty/Continuation.pm
 lib/Jifty/CurrentUser.pm
+lib/Jifty/DateTime.pm
 lib/Jifty/Dispatcher.pm
 lib/Jifty/Everything.pm
 lib/Jifty/Handle.pm
@@ -69,6 +73,7 @@
 lib/Jifty/Manual/Tutorial_ja.pod
 lib/Jifty/Mason/Halo.pm
 lib/Jifty/Model/Schema.pm
+lib/Jifty/Model/Session.pm
 lib/Jifty/Notification.pm
 lib/Jifty/Object.pm
 lib/Jifty/Record.pm
@@ -266,4 +271,3 @@
 t/TestApp/t/01-config.t
 t/TestApp/t/02-dispatch.t
 t/TestApp/t/03-static.t
-t/TestApp/web/templates/after

Modified: jifty/branches/jifty-jsan/Makefile.PL
==============================================================================
--- jifty/branches/jifty-jsan/Makefile.PL	(original)
+++ jifty/branches/jifty-jsan/Makefile.PL	Thu Apr 27 21:28:36 2006
@@ -13,6 +13,7 @@
 requires('Compress::Zlib');
 requires('DBD::SQLite');
 requires('Data::Page');
+requires('DateTime');
 requires('Date::Manip');
 requires('Email::Folder');
 requires('Email::LocalDelivery');

Modified: jifty/branches/jifty-jsan/lib/Jifty.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty.pm	Thu Apr 27 21:28:36 2006
@@ -3,7 +3,8 @@
 
 package Jifty;
 use encoding 'utf8';
-
+# Work around the fact that Time::Local caches thing on first require
+BEGIN { local $ENV{'TZ'} = "GMT";  require Time::Local;}
 our $VERSION = '0.60321';
 
 =head1 NAME

Modified: jifty/branches/jifty-jsan/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Action/Record.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Action/Record.pm	Thu Apr 27 21:28:36 2006
@@ -153,7 +153,7 @@
 
       elsif ( defined $column->refers_to ) {
         my $refers_to = $column->refers_to;
-        if ( ref($refers_to) and $refers_to->isa('Jifty::Record') ) {
+        if ( UNIVERSAL::isa($refers_to, 'Jifty::Record') ) {
 
           my $collection = Jifty::Collection->new(
             record_class => $refers_to,
@@ -263,10 +263,8 @@
     my $self = shift;
     my $val = shift;
     return undef unless defined $val and $val =~ /\S/;
-    my $epoch =  Date::Manip::UnixDate(Date::Manip::ParseDate($val),'%s');
-    return undef unless $epoch;
-    my $dt  = DateTime->from_epoch( epoch =>$epoch, time_zone => 'local');
-    return $dt->ymd;
+    return undef unless my $obj = Jifty::DateTime->new_from_string($val);
+    return $obj->ymd;
 }
 
 =head2 take_action

Modified: jifty/branches/jifty-jsan/lib/Jifty/ClassLoader.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/ClassLoader.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/ClassLoader.pm	Thu Apr 27 21:28:36 2006
@@ -127,18 +127,18 @@
         );
 
     } elsif ( $module
-        =~ m!^($ApplicationClassPrefix)::Action::(Create|Update|Delete)([^\.:]+)$!
+        =~ m!^($ApplicationClassPrefix)::Action::(Create|Update|Delete)([^\.]+)$!
         )
     {
          
-        # Auto-create CRUD classes
+        # Auto-create CRUD classes - this applies to model subclasses too
         my $modelclass = $ApplicationClassPrefix . "::Model::" . $3;
         Jifty::Util->require($modelclass);
 
         return undef unless eval {$modelclass->table}; #self->{models}{$modelclass};
 
         my $class = $ActionBasePath ."::".$2.$3;
-        return $self->return_class( "package " . $ActionBasePath . "::$2$3;\n"
+        return $self->return_class( "package $class;\n"
                 . "use base qw/Jifty::Action::Record::$2/;\n"
                 . "sub record_class {'$modelclass'};\n"
                 . "1;" );

Added: jifty/branches/jifty-jsan/lib/Jifty/DateTime.pm
==============================================================================
--- (empty file)
+++ jifty/branches/jifty-jsan/lib/Jifty/DateTime.pm	Thu Apr 27 21:28:36 2006
@@ -0,0 +1,85 @@
+use warnings;
+use strict;
+package Jifty::DateTime;
+
+
+=head1 NAME
+
+Jifty::DateTime - a DateTime subclass that knows about Jifty users 
+
+=head1 DESCRIPTION
+
+Jifty natively stores timestamps in the database in GMT.  Dates are stored
+without timezone. This class loads and parses dates and sets them 
+into the proper timezone.
+
+=cut
+
+use base qw'Jifty::Object DateTime';
+
+use Date::Manip ();
+
+=head2 new ARGS
+
+See L<DateTime/new>.  After calling that method, set this object's timezone
+to the current user's time zone, if the current user has a method called C<time_zone>.
+
+=cut
+
+sub new {
+  my $class = shift;
+  my %args  = (@_);
+  my $self  = $class->SUPER::new(%args);
+
+  # unless the user has explicitly said they want a floating time,
+  # we want to convert to the end-user's timezone
+  # This is complicated by the fact that DateTime auto-appends
+  $self->_get_current_user();
+  if ( $self->current_user->user_object
+        and  $self->current_user->user_object->can('time_zone')
+        and $self->current_user->user_object->time_zone )
+  {
+    $self->set_time_zone("UTC");
+    $self->set_time_zone( $self->current_user->user_object->time_zone );
+
+  }
+  return $self;
+}
+
+=head2 new_from_string STRING
+
+Take some user defined string like "tomorrow" and turn it into a C<Jifty::Datetime> object.  If the string appears to be a _date_, keep it in the floating timezone, otherwise, set it to the current user's timezone.
+
+
+=cut
+
+sub new_from_string {
+  my $class  = shift;
+  my $string = shift;
+  my $now;
+  { local $ENV{'TZ'} = "GMT"; 
+    $now = Date::Manip::UnixDate( $string, "%o" );
+  }
+  return undef unless $now;
+  my $self = $class->from_epoch( epoch => $now, time_zone => 'gmt' );
+  $self->_get_current_user();
+  if (  $self->current_user->user_object
+    and $self->current_user->user_object->can('time_zone')
+    and $self->current_user->user_object->time_zone )
+  {
+
+    # If the DateTime we've been handed appears to actually be at a "time"
+    # then we want to make sure we get it to be that time in the local
+    # timezone
+    #
+    # If we had only a date, then we want to switch it to the user's
+    # timezone without adjusting the "time", as that could make 2006-12-01
+    #  into 2006-11-30
+    $self->set_time_zone("floating")
+      unless ( $self->hour or $self->minute or $self->second );
+    $self->set_time_zone( $self->current_user->user_object->time_zone );
+  }
+  return $self;
+}
+
+1;

Modified: jifty/branches/jifty-jsan/lib/Jifty/Everything.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Everything.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Everything.pm	Thu Apr 27 21:28:36 2006
@@ -18,7 +18,7 @@
 use Jifty::ClassLoader ();
 use Jifty::Util ();
 use Jifty::API ();
-
+use Jifty::DateTime ();
 use Jifty::Record ();
 use Jifty::Collection ();
 use Jifty::Action ();

Modified: jifty/branches/jifty-jsan/lib/Jifty/Model/Session.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Model/Session.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Model/Session.pm	Thu Apr 27 21:28:36 2006
@@ -1,51 +1,2 @@
-use warnings;
-use strict;
-
-=head1 NAME
-
-Jifty::Model::Session - Tracks in-db session version
-
-=head1 SYNOPSIS
-
-  my $app = Jifty->new(config_file => "$ProjectRoot/etc/config.yml");
-  my $session = Jifty::Model::Session->new;
-  my $db_version = $session->in_db;
-
-=head1 DESCRIPTION
-
-Every Jifty application automatically inherits this table, which
-describes what version of the session is in the database currently.
-This allows Jifty to smartly upgrade between session versions.
-
-=cut
-
-package Jifty::Model::Session::Session;
-use Jifty::DBI::Session;
-
-
-column session_id => type is 'varchar(32)';
-column key => type is 'text';
-column value => type is 'text';
-column created => type is 'date';
-column updated => type is 'date';
-column key_type => type is varchar('32');
-
-package Jifty::Model::Session;
-use version;
-
-use base qw( Jifty::Record );
-
-=head2 table
-
-Sessions are stored in the table C<_jifty_sessions>.
-
-=cut
-
-sub table { '_jifty_sessions' }
-
-sub _init { } # we really don't need a current_user for this
-
-
-sub 
-
-1;
+package Jifty::Model::Session; 
+"TRUE, THIS IS A STUB FILE. SORRY";


More information about the Jifty-commit mailing list