moksha.spec setup.py
by Luke Macken
moksha.spec | 1 +
setup.py | 1 +
2 files changed, 2 insertions(+)
New commits:
commit afbfe76ec5175a4995e50b341a41dc37945a8b46
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Jul 27 02:03:27 2010 -0400
We now require BeautifulSoup
diff --git a/moksha.spec b/moksha.spec
index d4c594d..aa13e45 100644
--- a/moksha.spec
+++ b/moksha.spec
@@ -39,6 +39,7 @@ Requires: python-morbid
Requires: pytz
Requires: pyevent
Requires: python-repoze-who-testutil
+Requires: python-BeautifulSoup
%description
Moksha is a platform for creating real-time collaborative web applications. It
diff --git a/setup.py b/setup.py
index 5ff80cd..0c676af 100644
--- a/setup.py
+++ b/setup.py
@@ -41,6 +41,7 @@ setup(
"pytz",
"Babel",
"pyOpenSSL",
+ "BeautifulSoup",
#"repoze.squeeze", # Not hard requirements
#"repoze.profile", # Not hard requirements
],
13 years, 9 months
moksha/apps
by Luke Macken
moksha/apps/moksha.jit/moksha/widgets/mokshajit/spacetree.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
New commits:
commit 16135daa464c30fc40f59fb184a61c0b4cdcfd77
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Jul 21 17:39:36 2010 -0400
Remove some civx-ness from the spacetree
diff --git a/moksha/apps/moksha.jit/moksha/widgets/mokshajit/spacetree.py b/moksha/apps/moksha.jit/moksha/widgets/mokshajit/spacetree.py
index f8f01ac..90510df 100644
--- a/moksha/apps/moksha.jit/moksha/widgets/mokshajit/spacetree.py
+++ b/moksha/apps/moksha.jit/moksha/widgets/mokshajit/spacetree.py
@@ -33,16 +33,13 @@ jit_yc_js = JSLink(filename='static/jit-yc.js', javascript=[excanvas_js], modnam
jit_base_css = CSSLink(filename='static/css/base.css', modname=__name__)
jit_spacetree_css = CSSLink(filename='static/css/Spacetree.css', modname=__name__)
-# TODO: FIX ME BEFORE COMMITTING
-from civx.widgets.civx_js import civx_js
-
class SpaceTree(Widget):
params = {
'query': 'URL to query for JSON data',
'title': 'The title of this graph',
'description': 'A description of this graph',
}
- javascript = [jit_yc_js, civx_js]
+ javascript = [jit_yc_js]
css = [jquery_js, jit_base_css, jit_spacetree_css]
template = 'mako:moksha.widgets.mokshajit.templates.spacetree'
query = '/apps/mokshajit/query'
13 years, 10 months
moksha/lib
by Luke Macken
moksha/lib/helpers.py | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 951d5fc6358aedd2ffd880e4dff12c931ef7f168
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Jul 13 21:56:22 2010 -0400
Pull in an additional import into our helpers
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 9663401..dc7e0e2 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -26,6 +26,7 @@ import logging
import warnings
from orbited import json
+from UserDict import DictMixin
from tw.api import js_callback
from pytz import timezone, utc
from webob import Request
13 years, 10 months
moksha/connector moksha/lib
by Luke Macken
moksha/connector/utils.py | 47 +---------------------------------------------
moksha/lib/helpers.py | 46 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 45 deletions(-)
New commits:
commit 006cbb647c7df43f373b257edba653648f76fb06
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Jul 13 20:30:31 2010 -0400
Move our odict implementation out of moksha.connectors.utils and into moksha.lib.helpers
diff --git a/moksha/connector/utils.py b/moksha/connector/utils.py
index 964cd7c..a59b3ab 100644
--- a/moksha/connector/utils.py
+++ b/moksha/connector/utils.py
@@ -23,6 +23,8 @@ import warnings
from datetime import datetime
from UserDict import DictMixin
+from moksha.lib.helpers import odict
+
class DateTimeDisplay(object):
"""DateTimeDisplay is an object which takes any number of datetime objects
and process them for display.
@@ -102,51 +104,6 @@ class DateTimeDisplay(object):
return {'time':time, 'date':date , 'when':when, 'should_hide_time':should_hide_time}
-class odict(DictMixin):
-
- def __init__(self):
- self._keys = []
- self._data = {}
-
- def index(self, i):
- k = self._keys[i]
- return self._data[k]
-
- def key_index(self, i):
- return self._keys[i]
-
- def __setitem__(self, key, value):
- if key not in self._data:
- self._keys.append(key)
-
- self._data[key] = value
-
- def __getitem__(self, key):
- return self._data[key]
-
- def __delitem__(self, key):
- del self._data[key]
- self._keys.remove(key)
-
- def __iter__(self):
- for key in self._keys:
- yield key
-
- def keys(self):
- return list(self._keys)
-
- def copy(self):
- copyDict = odict()
- copyDict._data = self._data.copy()
- copyDict._keys = self._keys[:]
- return copyDict
-
- def __repr__(self):
- result = []
- for key in self._keys:
- result.append('(%s, %s)' % (repr(key), repr(self._data[key])))
- return ''.join(['OrderedDict', '([', ', '.join(result), '])'])
-
class QueryCol(dict):
def __init__(self,
column,
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index eb3ef1e..9663401 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -1059,3 +1059,49 @@ def listify(something):
return not isinstance(something, list) and [something] or something
else:
return []
+
+
+class odict(DictMixin):
+
+ def __init__(self):
+ self._keys = []
+ self._data = {}
+
+ def index(self, i):
+ k = self._keys[i]
+ return self._data[k]
+
+ def key_index(self, i):
+ return self._keys[i]
+
+ def __setitem__(self, key, value):
+ if key not in self._data:
+ self._keys.append(key)
+
+ self._data[key] = value
+
+ def __getitem__(self, key):
+ return self._data[key]
+
+ def __delitem__(self, key):
+ del self._data[key]
+ self._keys.remove(key)
+
+ def __iter__(self):
+ for key in self._keys:
+ yield key
+
+ def keys(self):
+ return list(self._keys)
+
+ def copy(self):
+ copyDict = odict()
+ copyDict._data = self._data.copy()
+ copyDict._keys = self._keys[:]
+ return copyDict
+
+ def __repr__(self):
+ result = []
+ for key in self._keys:
+ result.append('(%s, %s)' % (repr(key), repr(self._data[key])))
+ return ''.join(['OrderedDict', '([', ', '.join(result), '])'])
13 years, 10 months
moksha/apps
by Luke Macken
0 files changed
New commits:
commit 6ff0db3597885e899cc93908d0e1c734810c815d
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Jul 12 17:05:44 2010 -0400
Remove the moksha.controllers module in the metrics app, which seems
to be stomping on our namespace. We needed this to work around a Routes
issue, but I can't seem to reproduce it anymore.
diff --git a/moksha/apps/metrics/moksha/controllers/__init__.py b/moksha/apps/metrics/moksha/controllers/__init__.py
deleted file mode 100644
index e69de29..0000000
13 years, 10 months
moksha/apps
by Luke Macken
moksha/apps/knowledge/pavement.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit f2910f69276150f89773288f4eb77118d6bd15c6
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Jul 12 14:03:05 2010 -0400
Have the knowledge app pull in tgext.crud
diff --git a/moksha/apps/knowledge/pavement.py b/moksha/apps/knowledge/pavement.py
index 8bb2d45..ca9fae9 100644
--- a/moksha/apps/knowledge/pavement.py
+++ b/moksha/apps/knowledge/pavement.py
@@ -23,7 +23,7 @@ options(
'moksha',
'moksha.apps',
],
- install_requires=["Moksha"],
+ install_requires=["Moksha", "tgext.crud"],
entry_points="""
[moksha.application]
moksha.apps.knowledge = moksha.apps.knowledge.controllers.root:RootController
13 years, 10 months
2 commits - moksha/apps moksha/public moksha/widgets
by Luke Macken
moksha/apps/knowledge/moksha/apps/knowledge/model/model.py | 222 ++++++-------
moksha/apps/knowledge/pavement.py | 32 +
moksha/apps/knowledge/pavement.py.hide | 32 -
moksha/public/javascript/jquery.json.js | 156 ---------
moksha/widgets/json.py | 6
moksha/widgets/moksha_js.py | 4
moksha/widgets/static/jquery.json.js | 156 +++++++++
moksha/widgets/static/moksha.js | 1
8 files changed, 307 insertions(+), 302 deletions(-)
New commits:
commit 061449fb0caa477a3edd8a9da20f7ac19518e412
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Jul 12 13:57:22 2010 -0400
Move some of our javascript files around so we can pull them in from other apps
diff --git a/moksha/public/javascript/jquery.json.js b/moksha/public/javascript/jquery.json.js
deleted file mode 100644
index 225ca82..0000000
--- a/moksha/public/javascript/jquery.json.js
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * jQuery JSON Plugin
- * version: 1.0 (2008-04-17)
- *
- * This document is licensed as free software under the terms of the
- * MIT License: http://www.opensource.org/licenses/mit-license.php
- *
- * Brantley Harris technically wrote this plugin, but it is based somewhat
- * on the JSON.org website's http://www.json.org/json2.js, which proclaims:
- * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
- * I uphold. I really just cleaned it up.
- *
- * It is also based heavily on MochiKit's serializeJSON, which is
- * copywrited 2005 by Bob Ippolito.
- */
-
-(function($) {
- function toIntegersAtLease(n)
- // Format integers to have at least two digits.
- {
- return n < 10 ? '0' + n : n;
- }
-
- Date.prototype.toJSON = function(date)
- // Yes, it polutes the Date namespace, but we'll allow it here, as
- // it's damned usefull.
- {
- return this.getUTCFullYear() + '-' +
- toIntegersAtLease(this.getUTCMonth()) + '-' +
- toIntegersAtLease(this.getUTCDate());
- };
-
- var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g;
- var meta = { // table of character substitutions
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- };
-
- $.quoteString = function(string)
- // Places quotes around a string, inteligently.
- // If the string contains no control characters, no quote characters, and no
- // backslash characters, then we can safely slap some quotes around it.
- // Otherwise we must also replace the offending characters with safe escape
- // sequences.
- {
- if (escapeable.test(string))
- {
- return '"' + string.replace(escapeable, function (a)
- {
- var c = meta[a];
- if (typeof c === 'string') {
- return c;
- }
- c = a.charCodeAt();
- return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
- }) + '"';
- }
- return '"' + string + '"';
- };
-
- $.toJSON = function(o, compact)
- {
- var type = typeof(o);
-
- if (type == "undefined")
- return "undefined";
- else if (type == "number" || type == "boolean")
- return o + "";
- else if (o === null)
- return "null";
-
- // Is it a string?
- if (type == "string")
- {
- return $.quoteString(o);
- }
-
- // Does it have a .toJSON function?
- if (type == "object" && typeof o.toJSON == "function")
- return o.toJSON(compact);
-
- // Is it an array?
- if (type != "function" && typeof(o.length) == "number")
- {
- var ret = [];
- for (var i = 0; i < o.length; i++) {
- ret.push( $.toJSON(o[i], compact) );
- }
- if (compact)
- return "[" + ret.join(",") + "]";
- else
- return "[" + ret.join(", ") + "]";
- }
-
- // If it's a function, we have to warn somebody!
- if (type == "function") {
- throw new TypeError("Unable to convert object of type 'function' to json.");
- }
-
- // It's probably an object, then.
- var ret = [];
- for (var k in o) {
- var name;
- type = typeof(k);
-
- if (type == "number")
- name = '"' + k + '"';
- else if (type == "string")
- name = $.quoteString(k);
- else
- continue; //skip non-string or number keys
-
- var val = $.toJSON(o[k], compact);
- if (typeof(val) != "string") {
- // skip non-serializable values
- continue;
- }
-
- if (compact)
- ret.push(name + ":" + val);
- else
- ret.push(name + ": " + val);
- }
- return "{" + ret.join(", ") + "}";
- };
-
- $.compactJSON = function(o)
- {
- return $.toJSON(o, true);
- };
-
- $.evalJSON = function(src)
- // Evals JSON that we know to be safe.
- {
- return eval("(" + src + ")");
- };
-
- $.secureEvalJSON = function(src)
- // Evals JSON in a way that is *more* secure.
- {
- var filtered = src;
- filtered = filtered.replace(/\\["\\\/bfnrtu]/g, '@');
- filtered = filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']');
- filtered = filtered.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
-
- if (/^[\],:{}\s]*$/.test(filtered))
- return eval("(" + src + ")");
- else
- throw new SyntaxError("Error parsing JSON, source is not valid.");
- };
-})(jQuery);
diff --git a/moksha/widgets/json.py b/moksha/widgets/json.py
index ae790fe..5ffe086 100644
--- a/moksha/widgets/json.py
+++ b/moksha/widgets/json.py
@@ -1,2 +1,6 @@
from tw.api import JSLink
-jquery_json_js = JSLink(link='/javascript/jquery.json.js')
+from tw.jquery import jquery_js
+
+jquery_json_js = JSLink(modname=__name__,
+ filename='static/jquery.json.js',
+ javascript=[jquery_js])
diff --git a/moksha/widgets/moksha_js.py b/moksha/widgets/moksha_js.py
index 733be89..d11a88b 100644
--- a/moksha/widgets/moksha_js.py
+++ b/moksha/widgets/moksha_js.py
@@ -17,8 +17,8 @@
from tw.api import JSLink
from tw.jquery import jquery_js
-moksha_js = JSLink(modname="moksha",
- filename='public/javascript/moksha.js',
+moksha_js = JSLink(modname=__name__,
+ filename='static/moksha.js',
javascript=[jquery_js])
moksha_extension_points_js = JSLink(modname="moksha",
diff --git a/moksha/widgets/static/__init__.py b/moksha/widgets/static/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/moksha/widgets/static/jquery.json.js b/moksha/widgets/static/jquery.json.js
new file mode 100644
index 0000000..225ca82
--- /dev/null
+++ b/moksha/widgets/static/jquery.json.js
@@ -0,0 +1,156 @@
+/*
+ * jQuery JSON Plugin
+ * version: 1.0 (2008-04-17)
+ *
+ * This document is licensed as free software under the terms of the
+ * MIT License: http://www.opensource.org/licenses/mit-license.php
+ *
+ * Brantley Harris technically wrote this plugin, but it is based somewhat
+ * on the JSON.org website's http://www.json.org/json2.js, which proclaims:
+ * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
+ * I uphold. I really just cleaned it up.
+ *
+ * It is also based heavily on MochiKit's serializeJSON, which is
+ * copywrited 2005 by Bob Ippolito.
+ */
+
+(function($) {
+ function toIntegersAtLease(n)
+ // Format integers to have at least two digits.
+ {
+ return n < 10 ? '0' + n : n;
+ }
+
+ Date.prototype.toJSON = function(date)
+ // Yes, it polutes the Date namespace, but we'll allow it here, as
+ // it's damned usefull.
+ {
+ return this.getUTCFullYear() + '-' +
+ toIntegersAtLease(this.getUTCMonth()) + '-' +
+ toIntegersAtLease(this.getUTCDate());
+ };
+
+ var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g;
+ var meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ };
+
+ $.quoteString = function(string)
+ // Places quotes around a string, inteligently.
+ // If the string contains no control characters, no quote characters, and no
+ // backslash characters, then we can safely slap some quotes around it.
+ // Otherwise we must also replace the offending characters with safe escape
+ // sequences.
+ {
+ if (escapeable.test(string))
+ {
+ return '"' + string.replace(escapeable, function (a)
+ {
+ var c = meta[a];
+ if (typeof c === 'string') {
+ return c;
+ }
+ c = a.charCodeAt();
+ return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
+ }) + '"';
+ }
+ return '"' + string + '"';
+ };
+
+ $.toJSON = function(o, compact)
+ {
+ var type = typeof(o);
+
+ if (type == "undefined")
+ return "undefined";
+ else if (type == "number" || type == "boolean")
+ return o + "";
+ else if (o === null)
+ return "null";
+
+ // Is it a string?
+ if (type == "string")
+ {
+ return $.quoteString(o);
+ }
+
+ // Does it have a .toJSON function?
+ if (type == "object" && typeof o.toJSON == "function")
+ return o.toJSON(compact);
+
+ // Is it an array?
+ if (type != "function" && typeof(o.length) == "number")
+ {
+ var ret = [];
+ for (var i = 0; i < o.length; i++) {
+ ret.push( $.toJSON(o[i], compact) );
+ }
+ if (compact)
+ return "[" + ret.join(",") + "]";
+ else
+ return "[" + ret.join(", ") + "]";
+ }
+
+ // If it's a function, we have to warn somebody!
+ if (type == "function") {
+ throw new TypeError("Unable to convert object of type 'function' to json.");
+ }
+
+ // It's probably an object, then.
+ var ret = [];
+ for (var k in o) {
+ var name;
+ type = typeof(k);
+
+ if (type == "number")
+ name = '"' + k + '"';
+ else if (type == "string")
+ name = $.quoteString(k);
+ else
+ continue; //skip non-string or number keys
+
+ var val = $.toJSON(o[k], compact);
+ if (typeof(val) != "string") {
+ // skip non-serializable values
+ continue;
+ }
+
+ if (compact)
+ ret.push(name + ":" + val);
+ else
+ ret.push(name + ": " + val);
+ }
+ return "{" + ret.join(", ") + "}";
+ };
+
+ $.compactJSON = function(o)
+ {
+ return $.toJSON(o, true);
+ };
+
+ $.evalJSON = function(src)
+ // Evals JSON that we know to be safe.
+ {
+ return eval("(" + src + ")");
+ };
+
+ $.secureEvalJSON = function(src)
+ // Evals JSON in a way that is *more* secure.
+ {
+ var filtered = src;
+ filtered = filtered.replace(/\\["\\\/bfnrtu]/g, '@');
+ filtered = filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']');
+ filtered = filtered.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
+
+ if (/^[\],:{}\s]*$/.test(filtered))
+ return eval("(" + src + ")");
+ else
+ throw new SyntaxError("Error parsing JSON, source is not valid.");
+ };
+})(jQuery);
diff --git a/moksha/widgets/static/moksha.js b/moksha/widgets/static/moksha.js
new file mode 120000
index 0000000..acb0769
--- /dev/null
+++ b/moksha/widgets/static/moksha.js
@@ -0,0 +1 @@
+../../public/javascript/moksha.js
\ No newline at end of file
commit d1f3be55c353bbdd2626e6b67870458f420c289f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Jul 12 13:56:51 2010 -0400
Re-enable the knowledge app
diff --git a/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py b/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
index 54b76ef..ee67f33 100644
--- a/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
+++ b/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
@@ -22,114 +22,114 @@
.. moduleauthor:: Luke Macken <lmacken(a)redhat.com>
"""
-#from sqlalchemy import *
-#from sqlalchemy.orm import *
-#from sqlalchemy.orm.collections import attribute_mapped_collection
-#
-#from datetime import datetime
-#from sqlalchemy import *
-#from sqlalchemy.orm import relation, comparable_property
-#from sqlalchemy.orm.collections import attribute_mapped_collection
-#from vertical import PolymorphicVerticalProperty, VerticalPropertyDictMixin
-#
-##from moksha.model import metadata, DeclarativeBase, DBSession
-#from moksha.apps.knowledge.model import metadata, DeclarativeBase, DBSession
-#
-#
-#class Fact(PolymorphicVerticalProperty, DeclarativeBase):
-# """ A polymorphic-valued vertical table property """
-# __tablename__ = 'moksha_facts'
-#
-# id = Column(Integer, ForeignKey('moksha_entities.id'), primary_key=True)
-# key = Column(Unicode(64), primary_key=True)
-# type_ = Column(Unicode(16), default=None)
-# int_value = Column(Integer, default=None)
-# char_value = Column(UnicodeText, default=None)
-# boolean_value = Column(Boolean, default=None)
-# datetime_value = Column(DateTime, default=None)
-# list_value = Column(PickleType, default=None)
-# dict_value = Column(PickleType, default=None)
-#
-# value = comparable_property(PolymorphicVerticalProperty.Comparator,
-# PolymorphicVerticalProperty.value)
-#
-# type_map = {
-# int: (u'integer', 'int_value'),
-# str: (u'char', 'char_value'),
-# unicode: (u'char', 'char_value'),
-# bool: (u'boolean', 'boolean_value'),
-# datetime: (u'datetime', 'datetime_value'),
-# list: (u'list', 'list_value'),
-# dict: (u'dict', 'dict_value'),
-# type(None): (None, None),
-# }
-#
-#with_characteristic = lambda key, value: and_(Fact.key==key, Fact.value==value)
-#
-#
-#class Entity(VerticalPropertyDictMixin, DeclarativeBase):
-# """ An polymorphic entity.
-#
-# Entity facts are available via the 'facts' property or by using
-# dict-like accessors on an Entity instance::
-#
-# apple = Entity('apple')
-# apple['color'] = 'red'
-# # or, equivalently:
-# apple.facts['color'] = Fact('color', 'red')
-#
-# This Entity is also an adjacency tree. Meaning, every entity
-# can have a `parent` and zero or more `children`.
-# """
-# __tablename__ = 'moksha_entities'
-# _property_type = Fact
-# _property_mapping = 'facts'
-#
-# id = Column(Integer, autoincrement=True, primary_key=True)
-# name = Column(UnicodeText, nullable=False)
-#
-# facts = relation(Fact, backref='entity',
-# collection_class=attribute_mapped_collection('key'))
-#
-# # Adjacency tree properties
-# #id = Column(Integer, Sequence('moksha_tree_id_seq', optional=True), primary_key=True)
-# parent_id = Column(Integer, ForeignKey('moksha_entities.id'), nullable=True)
-#
-# children = relation('Entity', cascade="all",
-# backref=backref("parent", remote_side="Entity.id"),
-# collection_class=attribute_mapped_collection('name'),
-# lazy=False, join_depth=3)
-#
-# def __init__(self, name=None):
-# self.name = name
-#
-# @classmethod
-# def by_name(cls, name):
-# """A class method that permits to search entities
-# based on their name attribute.
-# """
-# return DBSession.query(cls).filter(cls.name==name).first()
-#
-# # Adjacency-tree methods
-# def append(self, node):
-# if isinstance(node, basestring):
-# node = Entity(node)
-# node.parent = self
-# self.children[node.name] = node
-#
-# def __repr__(self):
-# return self._getstring(0, False)
-#
-# def __str__(self):
-# return self._getstring(0, False)
-#
-# def _getstring(self, level, expand = False):
-# s = (' ' * level) + "%s (%s,%s, %d)" % (
-# self.name, self.id,self.parent_id,id(self)) + '\n'
-# if expand:
-# s += ''.join([n._getstring(level+1, True)
-# for n in self.children.values()])
-# return s
-#
-# def print_nodes(self):
-# return self._getstring(0, True)
+from sqlalchemy import *
+from sqlalchemy.orm import *
+from sqlalchemy.orm.collections import attribute_mapped_collection
+
+from datetime import datetime
+from sqlalchemy import *
+from sqlalchemy.orm import relation, comparable_property
+from sqlalchemy.orm.collections import attribute_mapped_collection
+from vertical import PolymorphicVerticalProperty, VerticalPropertyDictMixin
+
+#from moksha.model import metadata, DeclarativeBase, DBSession
+from moksha.apps.knowledge.model import metadata, DeclarativeBase, DBSession
+
+
+class Fact(PolymorphicVerticalProperty, DeclarativeBase):
+ """ A polymorphic-valued vertical table property """
+ __tablename__ = 'moksha_facts'
+
+ id = Column(Integer, ForeignKey('moksha_entities.id'), primary_key=True)
+ key = Column(Unicode(64), primary_key=True)
+ type_ = Column(Unicode(16), default=None)
+ int_value = Column(Integer, default=None)
+ char_value = Column(UnicodeText, default=None)
+ boolean_value = Column(Boolean, default=None)
+ datetime_value = Column(DateTime, default=None)
+ list_value = Column(PickleType, default=None)
+ dict_value = Column(PickleType, default=None)
+
+ value = comparable_property(PolymorphicVerticalProperty.Comparator,
+ PolymorphicVerticalProperty.value)
+
+ type_map = {
+ int: (u'integer', 'int_value'),
+ str: (u'char', 'char_value'),
+ unicode: (u'char', 'char_value'),
+ bool: (u'boolean', 'boolean_value'),
+ datetime: (u'datetime', 'datetime_value'),
+ list: (u'list', 'list_value'),
+ dict: (u'dict', 'dict_value'),
+ type(None): (None, None),
+ }
+
+with_characteristic = lambda key, value: and_(Fact.key==key, Fact.value==value)
+
+
+class Entity(VerticalPropertyDictMixin, DeclarativeBase):
+ """ An polymorphic entity.
+
+ Entity facts are available via the 'facts' property or by using
+ dict-like accessors on an Entity instance::
+
+ apple = Entity('apple')
+ apple['color'] = 'red'
+ # or, equivalently:
+ apple.facts['color'] = Fact('color', 'red')
+
+ This Entity is also an adjacency tree. Meaning, every entity
+ can have a `parent` and zero or more `children`.
+ """
+ __tablename__ = 'moksha_entities'
+ _property_type = Fact
+ _property_mapping = 'facts'
+
+ id = Column(Integer, autoincrement=True, primary_key=True)
+ name = Column(UnicodeText, nullable=False)
+
+ facts = relation(Fact, backref='entity',
+ collection_class=attribute_mapped_collection('key'))
+
+ # Adjacency tree properties
+ #id = Column(Integer, Sequence('moksha_tree_id_seq', optional=True), primary_key=True)
+ parent_id = Column(Integer, ForeignKey('moksha_entities.id'), nullable=True)
+
+ children = relation('Entity', cascade="all",
+ backref=backref("parent", remote_side="Entity.id"),
+ collection_class=attribute_mapped_collection('name'),
+ lazy=False, join_depth=3)
+
+ def __init__(self, name=None):
+ self.name = name
+
+ @classmethod
+ def by_name(cls, name):
+ """A class method that permits to search entities
+ based on their name attribute.
+ """
+ return DBSession.query(cls).filter(cls.name==name).first()
+
+ # Adjacency-tree methods
+ def append(self, node):
+ if isinstance(node, basestring):
+ node = Entity(node)
+ node.parent = self
+ self.children[node.name] = node
+
+ def __repr__(self):
+ return self._getstring(0, False)
+
+ def __str__(self):
+ return self._getstring(0, False)
+
+ def _getstring(self, level, expand = False):
+ s = (' ' * level) + "%s (%s,%s, %d)" % (
+ self.name, self.id,self.parent_id,id(self)) + '\n'
+ if expand:
+ s += ''.join([n._getstring(level+1, True)
+ for n in self.children.values()])
+ return s
+
+ def print_nodes(self):
+ return self._getstring(0, True)
diff --git a/moksha/apps/knowledge/pavement.py b/moksha/apps/knowledge/pavement.py
new file mode 100644
index 0000000..8bb2d45
--- /dev/null
+++ b/moksha/apps/knowledge/pavement.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+from paver.easy import *
+from paver.setuputils import (setup, find_package_data, find_packages,
+ install_distutils_tasks)
+install_distutils_tasks()
+from moksha.lib.paver_tasks import *
+
+options(
+ setup=Bunch(
+ name="moksha.knowledge",
+ version="0.1",
+ release="1",
+ url="http://moksha.fedorahosted.org",
+ description="Describe your package here",
+ license="AGPLv3",
+ long_description="",
+ author="",
+ author_email="",
+ rpm_name='moksha-apps-knowledge',
+ packages=find_packages(),
+ package_data=find_package_data(),
+ namespace_packages=[
+ 'moksha',
+ 'moksha.apps',
+ ],
+ install_requires=["Moksha"],
+ entry_points="""
+ [moksha.application]
+ moksha.apps.knowledge = moksha.apps.knowledge.controllers.root:RootController
+ """,
+ ),
+)
diff --git a/moksha/apps/knowledge/pavement.py.hide b/moksha/apps/knowledge/pavement.py.hide
deleted file mode 100644
index 8bb2d45..0000000
--- a/moksha/apps/knowledge/pavement.py.hide
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- coding: utf-8 -*-
-from paver.easy import *
-from paver.setuputils import (setup, find_package_data, find_packages,
- install_distutils_tasks)
-install_distutils_tasks()
-from moksha.lib.paver_tasks import *
-
-options(
- setup=Bunch(
- name="moksha.knowledge",
- version="0.1",
- release="1",
- url="http://moksha.fedorahosted.org",
- description="Describe your package here",
- license="AGPLv3",
- long_description="",
- author="",
- author_email="",
- rpm_name='moksha-apps-knowledge',
- packages=find_packages(),
- package_data=find_package_data(),
- namespace_packages=[
- 'moksha',
- 'moksha.apps',
- ],
- install_requires=["Moksha"],
- entry_points="""
- [moksha.application]
- moksha.apps.knowledge = moksha.apps.knowledge.controllers.root:RootController
- """,
- ),
-)
13 years, 10 months
moksha/apps
by Luke Macken
0 files changed
New commits:
commit e444279eb6d027fcc442ccdbd58353b18e06fcb7
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Jul 9 18:44:03 2010 -0400
Add an empty moksha.controllers module to get our unit tests working with the
latst Routes.
diff --git a/moksha/apps/metrics/moksha/controllers/__init__.py b/moksha/apps/metrics/moksha/controllers/__init__.py
new file mode 100644
index 0000000..e69de29
13 years, 10 months
moksha/lib
by Luke Macken
moksha/lib/helpers.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
New commits:
commit 1f0c882989af8eb64aed1f291197a60bb9362d1e
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Jul 9 18:38:26 2010 -0400
improve moksha.lib.helpers.listify to ensure we always return a list
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index f0b771c..eb3ef1e 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -1055,4 +1055,7 @@ def deprecation(message):
def listify(something):
- return not isinstance(something, list) and [something] or something
+ if something:
+ return not isinstance(something, list) and [something] or something
+ else:
+ return []
13 years, 10 months
moksha/api moksha/widgets
by Luke Macken
moksha/api/widgets/global_resources/widget.py | 8 ++------
moksha/widgets/moksha_js.py | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 6 deletions(-)
New commits:
commit 2eb77df057885ebb60bda57018745838722f6061
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Jul 9 17:56:09 2010 -0400
Break our moksha.js ToscaWidget out into it's own module
diff --git a/moksha/api/widgets/global_resources/widget.py b/moksha/api/widgets/global_resources/widget.py
index 356f0aa..0fb9417 100644
--- a/moksha/api/widgets/global_resources/widget.py
+++ b/moksha/api/widgets/global_resources/widget.py
@@ -24,13 +24,9 @@ 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')
+from moksha.widgets.moksha_js import moksha_js, moksha_extension_points_js
+log = logging.getLogger(__name__)
class GlobalResourceInjectionWidget(Widget):
"""
diff --git a/moksha/widgets/moksha_js.py b/moksha/widgets/moksha_js.py
new file mode 100644
index 0000000..733be89
--- /dev/null
+++ b/moksha/widgets/moksha_js.py
@@ -0,0 +1,26 @@
+# This file is part of Moksha.
+# Copyright (C) 2008-2010 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/>.
+
+from tw.api import JSLink
+from tw.jquery import jquery_js
+
+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])
13 years, 10 months