moksha/lib
by Luke Macken
moksha/lib/helpers.py | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit 7f42530b1e14798edb1eb8b7e0ef725555e433e4
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri May 29 13:08:02 2009 -0400
Make the DateTimeDisplay handle time.struct_time objects as well
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index fa1ff83..19e7587 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -951,6 +951,8 @@ class DateTimeDisplay(object):
self.timestamp = timestamp
if isinstance(timestamp, datetime):
self.datetime = timestamp
+ elif isinstance(timestamp, time.struct_time):
+ self.datetime = datetime(*timestamp[:-2])
elif isinstance(timestamp, basestring):
if hasattr(datetime, 'strptime'): # Python 2.5+
self.datetime = datetime.strptime(timestamp, format)
14 years, 11 months
3 commits - moksha/api moksha/lib
by Luke Macken
moksha/api/widgets/grid.py | 2 +-
moksha/lib/helpers.py | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
New commits:
commit 8758f2f6cc4682e2cd5f5b3920d389d2060537f2
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri May 29 06:11:37 2009 -0400
Allow our DateTimeDisplay.age method to take another DateTimeDisplay
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 29eb004..fa1ff83 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -981,6 +981,9 @@ class DateTimeDisplay(object):
start = self.datetime
if not end:
end = datetime.utcnow()
+ else:
+ if isinstance(end, DateTimeDisplay):
+ end = end.datetime
if tz:
zone = timezone(tz)
end = end.replace(tzinfo=utc)
commit d09bdc3f3ffe825e2e59e0a766271b38e97574ec
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri May 29 06:11:20 2009 -0400
Strip out trailing milli/micro seconds from timestamps after the in our DateTimeDisplay object
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 14b3bc4..29eb004 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -946,6 +946,8 @@ class DateTimeDisplay(object):
"""
def __init__(self, timestamp, format='%Y-%m-%d %H:%M:%S'):
+ if '.' in timestamp:
+ timestamp = timestamp.split('.')[0]
self.timestamp = timestamp
if isinstance(timestamp, datetime):
self.datetime = timestamp
commit 363116f24608da680b141646c86a601907cddaa1
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri May 29 06:10:48 2009 -0400
Move our when_ready import to the top of the module
diff --git a/moksha/api/widgets/grid.py b/moksha/api/widgets/grid.py
index 5b0b879..c417159 100644
--- a/moksha/api/widgets/grid.py
+++ b/moksha/api/widgets/grid.py
@@ -22,6 +22,7 @@ from tw.forms import FormField
from tw.jquery.ui_core import jquery_ui_core_js
from tw.jquery import jQuery, jquery_js
+from moksha.lib.helpers import when_ready
jquery_json_js = JSLink(filename='public/javascript/jquery.json.js',
modname='moksha', javascript=[jquery_js])
@@ -80,5 +81,4 @@ class Grid(FormField):
d['id'] += "-uuid" + str(uuid.uuid4())
- from moksha.lib.helpers import when_ready
self.add_call(when_ready(jQuery("#%s" % d['id']).mokshagrid(grid_d)))
14 years, 11 months
moksha.spec
by John (J5) Palmieri
moksha.spec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 068df3a6b089290f4cf705a1227cc01fc0a80848
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed May 27 18:14:40 2009 -0400
fix the bindir macro
diff --git a/moksha.spec b/moksha.spec
index 776f59b..0ac322c 100644
--- a/moksha.spec
+++ b/moksha.spec
@@ -77,7 +77,7 @@ information can be found on the Moksha Project Page at
%attr(-,apache,root) %{_localstatedir}/log/%{name}
%{python_sitelib}/%{name}-%{version}-py%{pyver}.egg-info/
%attr(-,apache,apache) %dir %{_localstatedir}/cache/%{name}
-%{bindir}/moksha-hub
+%{_bindir}/moksha-hub
%changelog
* Wed May 27 2009 John (J5) Palmieri <johnp(a)redhat.com> - 0.1-0.1
14 years, 11 months
moksha.spec
by John (J5) Palmieri
moksha.spec | 1 -
1 file changed, 1 deletion(-)
New commits:
commit 2f010b15a56e69c5524dc373d545eb1ff01f8a06
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed May 27 18:10:56 2009 -0400
we don't need TG2 to build
diff --git a/moksha.spec b/moksha.spec
index 2719dec..776f59b 100644
--- a/moksha.spec
+++ b/moksha.spec
@@ -16,7 +16,6 @@ BuildArch: noarch
BuildRequires: python-setuptools
BuildRequires: python-setuptools-devel
BuildRequires: python-devel
-BuildRequires: TurboGears2
BuildRequires: python-pygments
Requires: TurboGears2
14 years, 11 months
moksha.spec
by John (J5) Palmieri
moksha.spec | 1 +
1 file changed, 1 insertion(+)
New commits:
commit dfb8c3ee005817339f04e7e606a1e03c05e20d02
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed May 27 18:08:50 2009 -0400
add missing file to the file list
diff --git a/moksha.spec b/moksha.spec
index 378e5e8..2719dec 100644
--- a/moksha.spec
+++ b/moksha.spec
@@ -78,6 +78,7 @@ information can be found on the Moksha Project Page at
%attr(-,apache,root) %{_localstatedir}/log/%{name}
%{python_sitelib}/%{name}-%{version}-py%{pyver}.egg-info/
%attr(-,apache,apache) %dir %{_localstatedir}/cache/%{name}
+%{bindir}/moksha-hub
%changelog
* Wed May 27 2009 John (J5) Palmieri <johnp(a)redhat.com> - 0.1-0.1
14 years, 11 months
moksha.spec
by John (J5) Palmieri
moksha.spec | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
New commits:
commit 2f38308adfe90d069dbef4c5dddd4a5389d29df9
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed May 27 17:49:01 2009 -0400
first pass at rpm spec file
diff --git a/moksha.spec b/moksha.spec
new file mode 100644
index 0000000..378e5e8
--- /dev/null
+++ b/moksha.spec
@@ -0,0 +1,85 @@
+%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+%{!?pyver: %define pyver %(%{__python} -c "import sys ; print sys.version[:3]")}
+
+Name: moksha
+Version: 0.1dev
+Release: 0.1%{?dist}
+Summary: A flexable platform for creating live collaborative web applications
+Group: Applications/Internet
+License: AGPLv3
+URL: https://fedorahosted.org/moksha
+Source0: moksha-%{version}.tar.bz2
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch: noarch
+
+BuildRequires: python-setuptools
+BuildRequires: python-setuptools-devel
+BuildRequires: python-devel
+BuildRequires: TurboGears2
+BuildRequires: python-pygments
+
+Requires: TurboGears2
+Requires: ToscaWidgets >= 0.9.1,
+Requires: zope.sqlalchemy,
+Requires: Shove,
+Requires: feedcache,
+Requires: feedparser,
+Requires: tw.jquery>=0.9.4.1,
+Requires: repoze.squeeze,
+Requires: repoze.profile,
+Requires: orbited,
+Requires: twisted,
+Requires: python-stomper,
+Requires: Sphinx,
+Requires: Paver,
+Requires: tw.forms,
+Requires: python-morbid
+Requires: ptz
+Requires: pyevent
+
+%description
+Moksha is a platform for creating real-time collaborative web applications. It
+provides a set of Python and JavaScript API's that make it simple to create
+rich applications that can acquire, manipulate, and visualize data from
+external services. It is a unified framework build using the best available
+open source technologies such as TurboGears2, jQuery, AMQP, and Orbited. More
+information can be found on the Moksha Project Page at
+
+%prep
+%setup -q
+
+%build
+%{__python} setup.py build
+
+%install
+%{__rm} -rf %{buildroot}
+%{__python} setup.py install -O1 --skip-build \
+ --install-data=%{_datadir} --root %{buildroot}
+
+%{__mkdir_p} %{buildroot}%{_datadir}/%{name}/apache
+%{__mkdir_p} -m 0755 %{buildroot}/%{_localstatedir}/log/%{name}
+%{__mkdir_p} -m 0700 %{buildroot}/%{_localstatedir}/cache/%{name}
+
+%{__install} -m 640 apache/%{name}.conf %{buildroot}%{_datadir}/%{name}/apache
+
+%{__install} apache/%{name}.wsgi %{buildroot}%{_datadir}/%{name}/%{name}.wsgi
+%{__install} sample-production.ini %{buildroot}%{_datadir}/%{name}/production.ini
+
+%clean
+%{__rm} -rf %{buildroot}
+
+
+%files
+%defattr(-,root,root,-)
+%doc README
+%{python_sitelib}/%{name}/
+%attr(-,apache,root) %{_datadir}/%{name}
+%attr(-,apache,root) %{_localstatedir}/log/%{name}
+%{python_sitelib}/%{name}-%{version}-py%{pyver}.egg-info/
+%attr(-,apache,apache) %dir %{_localstatedir}/cache/%{name}
+
+%changelog
+* Wed May 27 2009 John (J5) Palmieri <johnp(a)redhat.com> - 0.1-0.1
+- first package
+
14 years, 11 months
setup.py
by John (J5) Palmieri
setup.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
New commits:
commit 170c657f71edc4cec35c92e19a84a269a43798e2
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed May 27 17:44:37 2009 -0400
make sure we are more fine grained when selecting files
diff --git a/setup.py b/setup.py
index 6b27c0e..4e88958 100644
--- a/setup.py
+++ b/setup.py
@@ -47,7 +47,13 @@ setup(
tests_require=['WebTest', 'BeautifulSoup'],
package_data={'moksha': ['i18n/*/LC_MESSAGES/*.mo',
'templates/*/*',
- 'public/*/*']},
+ 'public/favicon',
+ 'public/css/*.css',
+ 'public/images/*.png',
+ 'public/images/*.gif',
+ 'public/images/*.jpg',
+ 'public/javascript/*.js',
+ 'public/javascript/ui/*.js']},
message_extractors = {'moksha': [
('**.py', 'python', None),
('templates/**.mako', 'mako', None),
14 years, 11 months
moksha/api
by Luke Macken
moksha/api/widgets/containers/tabbedcontainer.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit c1db601e75f8a4ea170a01e8200ac65e9f57c0ec
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun May 24 22:37:15 2009 -0400
Create our tabs when the document is ready
diff --git a/moksha/api/widgets/containers/tabbedcontainer.py b/moksha/api/widgets/containers/tabbedcontainer.py
index 8582188..1eea20f 100644
--- a/moksha/api/widgets/containers/tabbedcontainer.py
+++ b/moksha/api/widgets/containers/tabbedcontainer.py
@@ -19,7 +19,7 @@ from tw.api import Widget, JSLink, js_function
from tw.forms import FormField
from pylons import config, request
from repoze.what import predicates
-from moksha.lib.helpers import eval_app_config, ConfigWrapper
+from moksha.lib.helpers import eval_app_config, ConfigWrapper, when_ready
moksha_ui_tabs_js = JSLink(modname='moksha', filename='public/javascript/ui/moksha.ui.tabs.js', javascript=[jquery_ui_tabs_js])
@@ -80,7 +80,7 @@ class TabbedContainer(FormField):
'tabdefault': d.get('tabdefault', 0),
'staticLoadOnClick': d.get('staticLoadOnClick', False)
}
- self.add_call(jQuery("#%s" % d.id).mokshatabs(o))
+ self.add_call(when_ready(jQuery("#%s" % d.id).mokshatabs(o)))
tabs = eval_app_config(config.get(self.config_key, "None"))
if not tabs:
14 years, 12 months
3 commits - moksha/api moksha/lib setup.py
by Luke Macken
moksha/api/widgets/global_resources/widget.py | 49 ++++++++++++++++-
moksha/api/widgets/grid.py | 10 ++-
moksha/api/widgets/moksha.py | 71 --------------------------
moksha/lib/helpers.py | 13 ++++
setup.py | 1
5 files changed, 65 insertions(+), 79 deletions(-)
New commits:
commit c13df0c81e64bb464a6bcd1dec424ff031cb9286
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun May 24 22:12:20 2009 -0400
Use the new ``when_ready`` method to fix a race-condition in the Grid widget
diff --git a/moksha/api/widgets/grid.py b/moksha/api/widgets/grid.py
index 29f7c09..5b0b879 100644
--- a/moksha/api/widgets/grid.py
+++ b/moksha/api/widgets/grid.py
@@ -14,12 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from tw.api import JSLink
+import uuid
+import simplejson as json
+
+from tw.api import JSLink, js_callback
from tw.forms import FormField
from tw.jquery.ui_core import jquery_ui_core_js
from tw.jquery import jQuery, jquery_js
-import simplejson as json
-import uuid
jquery_json_js = JSLink(filename='public/javascript/jquery.json.js',
@@ -79,4 +80,5 @@ class Grid(FormField):
d['id'] += "-uuid" + str(uuid.uuid4())
- self.add_call(jQuery("#%s" % d['id']).mokshagrid(grid_d))
+ from moksha.lib.helpers import when_ready
+ self.add_call(when_ready(jQuery("#%s" % d['id']).mokshagrid(grid_d)))
commit cf5f0634e9e5962d6f43e85b96bfc99814c111f8
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun May 24 22:11:19 2009 -0400
Add a moksha.lib.helpers.when_ready method.
This method takes a js_function and returns a js_callback that will run
when the document is ready. This is best used in conjunction with the
Widget.add_call method.
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index c531dd6..14b3bc4 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -25,6 +25,7 @@ import re
import os
import logging
+from tw.api import js_callback
from pytz import timezone, utc
from webob import Request
from decorator import decorator
@@ -994,3 +995,15 @@ class DateTimeDisplay(object):
def __str__(self):
return self.datetime.strftime('%Y-%m-%d %H:%M:%S %Z%z')
+
+
+def when_ready(func):
+ """
+ Takes a js_function and returns a js_callback that will run
+ when the document is ready.
+
+ >>> from tw.api import js_function
+ >>> print when_ready(js_function('jQuery')('foo').bar({'biz': 'baz'}))
+ $(document).ready(function(){jQuery("foo").bar({"biz": "baz"})});
+ """
+ return js_callback('$(document).ready(function(){' + str(func) + '});')
commit 0211a0febe6164b646ac61e78c92840aec68a63a
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun May 24 22:09:12 2009 -0400
Merge the MokshaGlobals widget with the GlobalResourceInjectionWidget.
Having a module called `moksha` was starting to cause problems.
diff --git a/moksha/api/widgets/global_resources/widget.py b/moksha/api/widgets/global_resources/widget.py
index 8cc518b..f9f1b46 100644
--- a/moksha/api/widgets/global_resources/widget.py
+++ b/moksha/api/widgets/global_resources/widget.py
@@ -17,11 +17,21 @@
import logging
import pkg_resources
-from inspect import isclass
+from tg import config, url
from tw.api import Widget, CSSLink, JSLink
+from tw.jquery import jquery_js
+from paste.deploy.converters import asbool
+from pylons import request
+from inspect import isclass
log = logging.getLogger(__name__)
+moksha_js = JSLink(modname="moksha", filename='public/javascript/moksha.js',
+ javascript=[jquery_js])
+moksha_extension_points_js = JSLink(modname="moksha", javascript=[moksha_js],
+ filename='public/javascript/moksha.extensions.js')
+
+
class GlobalResourceInjectionWidget(Widget):
"""
This widget will pull in all JSLink, CSSLink, and Widget resources that
@@ -33,16 +43,30 @@ class GlobalResourceInjectionWidget(Widget):
handles this for us, otherwise you can import the `global_resources`
widget from this module and do it yourself.
"""
- javascript = []
+ javascript = [moksha_js]
children = []
css = []
template = """
% for child in c:
${child()}
% endfor
- """
+ <script type="text/javascript">
+ moksha_base_url = "${base_url}";
+ moksha_csrf_token = "${csrf_token}";
+ moksha_userid = "${user_id}";
+ moksha_debug = ${debug};
+ moksha_profile = ${profile};
+ </script>
+ """
engine_name = 'mako'
+ params = ['base_url', 'csrf_token', 'user_id', 'debug', 'profile']
+ base_url = '/'
+ csrf_token = ''
+ user_id = ''
+ debug = 'false'
+ profile = 'false'
+
def __init__(self):
super(GlobalResourceInjectionWidget, self).__init__()
for widget_entry in pkg_resources.iter_entry_points('moksha.global'):
@@ -61,4 +85,23 @@ class GlobalResourceInjectionWidget(Widget):
"either a JSLink or CSSLink." %
widget_entry.name)
+ self.csrf_token_id = config.get('moksha.csrf.token_id', '_csrf_token')
+ if asbool(config.get('moksha.extensionpoints', False)):
+ self.javascript.append(moksha_extension_points_js)
+
+ def update_params(self, d):
+ super(GlobalResourceInjectionWidget, self).update_params(d)
+
+ d['base_url'] = url('/')
+
+ if asbool(config.get('debug')):
+ d['debug'] = 'true'
+ if asbool(config['global_conf'].get('profile')):
+ d['profile'] = 'true'
+
+ identity = request.environ.get('repoze.who.identity')
+ if identity:
+ d['csrf_token'] = identity.get(self.csrf_token_id, '')
+ d['user_id'] = identity.get('user_id', '')
+
global_resources = GlobalResourceInjectionWidget()
diff --git a/moksha/api/widgets/moksha.py b/moksha/api/widgets/moksha.py
deleted file mode 100644
index 97ece50..0000000
--- a/moksha/api/widgets/moksha.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# This file is part of Moksha.
-# Copyright (C) 2008-2009 Red Hat, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Authors: John (J5) Palmieri <johnp(a)redhat.com>
-
-import tg
-import pylons
-
-from tw.api import JSLink
-from tw.api import Widget
-from tw.jquery import jquery_js
-from paste.deploy.converters import asbool
-
-moksha_js = JSLink(modname="moksha", filename='public/javascript/moksha.js',
- javascript=[jquery_js])
-moksha_extension_points_js = JSLink(modname="moksha",
- filename='public/javascript/moksha.extensions.js',
- javascript=[moksha_js])
-
-class MokshaGlobals(Widget):
- javascript = [moksha_js]
- template = """<script type="text/javascript">
-moksha_base_url = "${base_url}";
-moksha_csrf_token = "${csrf_token}";
-moksha_userid = "${user_id}";
-moksha_debug = ${debug};
-moksha_profile = ${profile};
-</script>
-"""
- params = ['base_url', 'csrf_token', 'user_id', 'debug', 'profile']
- engine_name = 'mako'
-
- base_url = '/'
- csrf_token = ''
- user_id = ''
- debug = 'false'
- profile = 'false'
-
- def __init__(self, *args, **kw):
- super(MokshaGlobals, self).__init__(*args, **kw)
- self.csrf_token_id = tg.config.get('moksha.csrf.token_id', '_csrf_token')
- if asbool(tg.config.get('moksha.extensionpoints', False)):
- self.javascript.append(moksha_extension_points_js)
-
- def update_params(self, d):
- super(MokshaGlobals, self).update_params(d)
-
- d['base_url'] = tg.url('/')
-
- if asbool(pylons.config.get('debug')):
- d['debug'] = 'true'
- if asbool(pylons.config['global_conf'].get('profile')):
- d['profile'] = 'true'
-
- identity = pylons.request.environ.get('repoze.who.identity')
- if identity:
- d['csrf_token'] = identity.get(self.csrf_token_id, '')
- d['user_id'] = identity.get('user_id', '')
diff --git a/setup.py b/setup.py
index 212b782..6b27c0e 100644
--- a/setup.py
+++ b/setup.py
@@ -103,7 +103,6 @@ setup(
MokshaMessageMetricsWidget = moksha.widgets.metrics:MokshaMessageMetricsWidget
[moksha.global]
- moksha = moksha.api.widgets.moksha:MokshaGlobals
# The pipeline for our live widgets
stomp_js = moksha.api.widgets.stomp:stomp_js
14 years, 12 months
3 commits - moksha/lib
by Luke Macken
moksha/lib/helpers.py | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
New commits:
commit 92a0a6d70ba738defb1e57a2d51ad7ab02a2f42a
Merge: 1b2c9f1... c8c5b99...
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri May 22 00:04:44 2009 -0400
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/moksha
commit 1b2c9f12534506e3fc252674f20d5e455c82d53f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri May 22 00:03:29 2009 -0400
Add a 'general' argument to the DateTimeDisplay.age method.
This will only return the most significant granularity of time.
This solves the problems mentioned in:
https://fedorahosted.org/fedoracommunity/ticket/181
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index c1dfe72..a67bc60 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -964,18 +964,34 @@ class DateTimeDisplay(object):
zone = timezone(tz)
return zone.normalize(timestamp.astimezone(zone))
- def age(self, end=None, tz=None, granularity='hour'):
+ def age(self, end=None, tz=None, granularity='hour', general=False):
"""
Return the distance of time in words from `self.datetime` to `end`.
+
+ >>> start = datetime(1984, 11, 02)
+ >>> now = datetime(2009, 5, 22, 12, 11, 10)
+ >>> DateTimeDisplay(start).age(now)
+ '2 decades, 4 years, 6 months, 20 days and 12 hours'
+ >>> DateTimeDisplay(start).age(now, general=True)
+ '2 decades'
+
"""
start = self.datetime
if not end:
end = datetime.utcnow()
if tz:
zone = timezone(tz)
- #end = zone.localize(end)
end = end.replace(tzinfo=utc)
end = zone.normalize(end.astimezone(zone))
start = self.astimezone(tz)
- return distance_of_time_in_words(start, end, granularity=granularity)
+ age = distance_of_time_in_words(start, end, granularity=granularity)
+
+ if general:
+ if not age.startswith('less than'):
+ age = age.split('and')[0].split(',')[0]
+
+ return age
+
+ def __str__(self):
+ return self.datetime.strftime('%Y-%m-%d %H:%M:%S %Z%z')
commit ff41731d379fc209e397a6e2781d23f1b3db6699
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri May 22 00:03:14 2009 -0400
Minor doctest improvement
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 70954a4..c1dfe72 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -930,6 +930,8 @@ class DateTimeDisplay(object):
>>> now = datetime(2009, 5, 12)
>>> later = datetime(2009, 5, 13)
>>> d = DateTimeDisplay(now)
+ >>> print d
+ 2009-05-12 00:00:00
>>> d.age(later)
'1 day'
>>> d.age(datetime(2010, 7, 10, 10, 10), granularity='minute')
14 years, 12 months