Package turbogears :: Package toolbox :: Package catwalk :: Class CatWalk

Class CatWalk

source code

            object --+    
                     |    
controllers.Controller --+
                         |
                        CatWalk

Model Browser.

An administration tool for listing, creating, updating or deleting your SQLObject instances.


Version: 0.9

Author: Ronald Jaramillo

Copyright: Copyright 2005 Ronald Jaramillo

License: MIT

Instance Methods
 
__init__(self, model=None)
CatWalk's initializer.
source code
 
register_static_directory(self) source code
 
error(self, msg='', *_decorator__varargs, **_decorator__kwargs)
Generic error handler for json replies.
source code
 
load_object(self, object_name)
Return a class reference from the models module by name.
source code
 
load_instance(self, object_name, id)
Return and instance of the named object with the requested id
source code
 
object_field(self, row, column)
Get object field.
source code
 
multiple_join_count(self, row, column)
Return the total number of related objects.
source code
 
related_join_count(self, row, column)
Return the total number of related objects.
source code
 
object_field_for_foreign_key(self, row, column)
Return the foreign key value.
source code
 
update_object(self, object_name, id, values) source code
 
remove_related_joins_if_any(self, object_name, id)
Remove any related joins the object may have.
source code
 
remove_object(self, object_name, id)
Remove the object by id.
source code
 
extract_parameters(self, cols, values)
Loop trough the columns and extract the values from the dictionary.
source code
 
extract_foreign_key(self, values, column_name) source code
 
extract_decimal_value(self, values, column_name) source code
 
object_instances(self, object_name, start=0)
Return dictionary containing all instances for the requested object.
source code
 
foreign_key_alternatives(self, foreign_key, column_label)
Return list of dictionaries containing the posible foreignKey values.
source code
 
encode_label(self, label) source code
 
headers_and_rows(self, objectName, rows)
Return a tuple containing a list of rows and header labels.
source code
 
object_joins(self, objectName, id, join, joinType, joinObjectName='')
Collect the joined instances into a dictionary.
source code
 
object_representation(self, obj)
Utility method that returns a stripped object representation.
source code
 
get_column_type(self, column)
Given a column representation return the column type.
source code
 
column_title(self, column) source code
 
column_default(self, column, column_type) source code
 
get_column_properties(self, column_name, column)
Return a dictionary containing the column properties.
source code
 
get_string_properties(self, column, properties)
Extract the SOStringCol properties from the column object.
source code
 
get_foreign_key_properties(self, column, properties)
Extract the foreignKey properties from the column object.
source code
 
object_columns(self, object_name)
Return list of columns properties arranged in dicts.
source code
 
get_columns_for_object(self, obj)
Return list of columns properties arranged in dicts.
source code
 
get_inherited_columns(self, obj)
Return the columns inherited from the parent class
source code
 
is_inheritable_base_class(self, obj)
Check if the object is a direct subclass of InheritableSQLObject
source code
 
state_path(self)
Return the path to the catwalk session pickle.
source code
 
load_state(self)
Retrieve the pickled state from disc.
source code
 
save_state(self, state)
Pickle the state.
source code
 
hide_columns(self, view, columns='') source code
 
toggle_columns_visibility_state(self, view, columns)
Toggle the columns visibility and store the new state.
source code
 
load_columns_visibility_state(self, view)
Return a list of hidden columns names for the requested view.
source code
 
load_label_column_for_object(self, objectName)
Get the column name (foreignKey label) for an object.
source code
 
column_label_for_object(self, objectName, columnName)
Store the column name (foreignKey label) for an object.
source code
 
load_column_order(self, object_name)
Get the column order.
source code
 
save_column_order(self, object_name, columns_bsv)
Save the prefered order of the object's columns.
source code
 
order_columns(self, object_name, cols)
Return a rearrenged list of columns as configured by the user.
source code
 
save_model_order(self, models)
Store the new order of the listed models.
source code
 
load_models_order(self) source code
 
order_models(self, models) source code
 
add(self, *_decorator__varargs, **v)
Create a new instance of an object.
source code
 
update(self, *_decorator__varargs, **values)
Update the objects properties.
source code
 
remove(self, objectName, id, *_decorator__varargs, **_decorator__kwargs)
Remove and instance by id.
source code
 
remove_single_join(self, object_name, id, join_object_name, join_object_id, *_decorator__varargs, **_decorator__kwargs)
Remove a single join instance by id.
source code
 
saveModelOrder(self, models, *_decorator__varargs, **_decorator__kwargs)
Save the prefered order of the listed models.
source code
 
columnOrder(self, objectName, cols, *_decorator__varargs, **_decorator__kwargs)
Save the prefered order of the object's columns.
source code
 
instances(self, objectName, start=0, *_decorator__varargs, **_decorator__kwargs)
Get object instances.
source code
 
manageRelatedJoins(self, objectName, id, join, relatedObjectName, *_decorator__varargs, **vargs)
Get related joins.
source code
 
updateJoins(self, objectName, id, join, joinType, joinObjectName, joins, *_decorator__varargs, **_decorator__kwargs)
Update joins.
source code
 
updateColumns(self, objectName, column, *_decorator__varargs, **_decorator__kwargs)
Update a column.
source code
 
updateColumnsJoinView(self, objectName, id, join, joinType, joinObjectName, column, *_decorator__varargs, **_decorator__kwargs)
Update column in join view.
source code
 
joins(self, objectName, id, join, joinType, joinObjectName, *_decorator__varargs, **_decorator__kwargs)
Get joins.
source code
 
object_instance(self, object_name, id) source code
 
instance(self, objectName, id, *_decorator__varargs, **_decorator__kwargs)
Get object instance.
source code
 
columnsForLabel(self, objectName, foreignObjectName, foreignKeyName, *_decorator__varargs, **_decorator__kwargs)
Get columns for label.
source code
 
setColumnForLabel(self, objectName, foreignObjectName, foreignKeyName, columnName, *_decorator__varargs, **_decorator__kwargs)
Set columns for label.
source code
 
columns(self, objectName, *_decorator__varargs, **kv)
Return JSON structure containing a list of column properties.
source code
 
models(self) source code
 
list(self, *_decorator__varargs, **_decorator__kwargs)
Return JSON structure containing a list of available objects.
source code
 
index(self, *_decorator__varargs, **_decorator__kwargs)
Main CatWalk page.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables
  __label__ = 'CatWalk'
  __email__ = 'ronald@checkandshare.com'
  browse = Browse()
  need_project = True
  icon = '/tg_static/images/catwalk.png'
Properties

Inherited from object: __class__

Method Details

__init__(self, model=None)
(Constructor)

source code 

CatWalk's initializer.

Parameters:
  • model (yourproject.model) - reference to a project model module
Overrides: object.__init__

load_object(self, object_name)

source code 

Return a class reference from the models module by name.

Parameters:
  • object_name (string) - name of the object

object_field(self, row, column)

source code 

Get object field.

Returns a dict containing the column name and value for the specific column and row,

Parameters:
  • row - model instance
  • column (dict) - dict containing columnName, title, type, eventually join, joinMethodName and/or options

extract_parameters(self, cols, values)

source code 

Loop trough the columns and extract the values from the dictionary.

Parameters:
  • cols - column list
  • values - dict of submited values

object_instances(self, object_name, start=0)

source code 

Return dictionary containing all instances for the requested object.

Parameters:
  • object_name (string) - name of the object

foreign_key_alternatives(self, foreign_key, column_label)

source code 

Return list of dictionaries containing the posible foreignKey values.

Parameters:
  • foreign_key (string) - name of the foreignKey object
  • column_label (string) - name of the column to use as instance identifier

headers_and_rows(self, objectName, rows)

source code 

Return a tuple containing a list of rows and header labels.

Parameters:
  • objectName (string) - name of the object
  • rows - list of intances

object_joins(self, objectName, id, join, joinType, joinObjectName='')

source code 

Collect the joined instances into a dictionary.

Parameters:
  • objectName (string) - name of the object
  • id (string) - id of the instance
  • join (string) - name of the join (joinMethodName in SQLObject parlance)
  • joinType (string) - name of join type
  • joinObjectName (string) - otherClassName (in SQLObject parlance)

get_column_properties(self, column_name, column)

source code 

Return a dictionary containing the column properties.

Depending on the column type the properties returned could be: type, title, join (otherClassName), joinMethodName, length, varchar,labelColumn,opetions

Parameters:
  • column_name (string) - name of the column
  • column - column instance

object_columns(self, object_name)

source code 

Return list of columns properties arranged in dicts.

Parameters:
  • object_name (string) - name of the object

get_columns_for_object(self, obj)

source code 

Return list of columns properties arranged in dicts.

Parameters:
  • object - model instance

state_path(self)

source code 

Return the path to the catwalk session pickle.

Create a session directory if nescesary.

toggle_columns_visibility_state(self, view, columns)

source code 

Toggle the columns visibility and store the new state.

Parameters:
  • view (string) - name of the grid view to be stored
  • columns - name of the columns to be hidden or shown
  • column (bar separated string)

load_columns_visibility_state(self, view)

source code 

Return a list of hidden columns names for the requested view.

Parameters:
  • view (string) - name of the grid view to be stored

load_label_column_for_object(self, objectName)

source code 

Get the column name (foreignKey label) for an object.

Parameters:
  • objectName (string) - name of the object

column_label_for_object(self, objectName, columnName)

source code 

Store the column name (foreignKey label) for an object.

Parameters:
  • objectName (string) - name of the object
  • columnName (string) - name of the column to use as foreignKey label

load_column_order(self, object_name)

source code 

Get the column order.

If the user has rearrenged the columns order for an object, this will return the prefered order as list.

Parameters:
  • object_name (string) - name of the object

save_column_order(self, object_name, columns_bsv)

source code 
Save the prefered order of the object's columns.

@param object_name: name of the object
@type object_name: string
@param columns_bsv: bar (|) delimited columns names
   @type columns_bsv: string

order_columns(self, object_name, cols)

source code 

Return a rearrenged list of columns as configured by the user.

Parameters:
  • object_name (string) - name of the object
  • cols (list) - original list of columns following the default table order

add(self, *_decorator__varargs, **v)

source code 

Create a new instance of an object.

Parameters:
  • v - dictionary of submited values

update(self, *_decorator__varargs, **values)

source code 

Update the objects properties.

Parameters:
  • values - dictionary of key and values, as a bare minimum the name of the object (objectName) and the id

remove(self, objectName, id, *_decorator__varargs, **_decorator__kwargs)

source code 

Remove and instance by id.

This doesn't handle references (cascade delete).

Parameters:
  • objectName (string) - name of the object
  • id (string) - id of the instance to be removed

remove_single_join(self, object_name, id, join_object_name, join_object_id, *_decorator__varargs, **_decorator__kwargs)

source code 

Remove a single join instance by id.

This doesn't handle references (cascade delete).

Parameters:
  • object_name (string) - name of the host object
  • id (string) - id of the host instance
  • join_object_name (string) - name of the join object
  • join_object_id (string) - id of the join instance to be removed

columnOrder(self, objectName, cols, *_decorator__varargs, **_decorator__kwargs)

source code 

Save the prefered order of the object's columns.

Parameters:
  • objectName (string) - name of the object
  • cols (string) - columns names separated by '|'

instances(self, objectName, start=0, *_decorator__varargs, **_decorator__kwargs)

source code 

Get object instances.

Returns a JSON structure containing all instances of the requested object.

Parameters:
  • objectName (string) - name of the object

manageRelatedJoins(self, objectName, id, join, relatedObjectName, *_decorator__varargs, **vargs)

source code 

Get related joins.

Returns a JSON structure whith a list of related joins for the requested object, and a list of all joins.

Parameters:
  • objectName (string) - name of the object
  • id (string) - id of the instance
  • join (string) - name of the join (joinMethodName in SQLObject parlance)
  • relatedObjectName (string) - otherClassName (in SQLObject parlance)

updateJoins(self, objectName, id, join, joinType, joinObjectName, joins, *_decorator__varargs, **_decorator__kwargs)

source code 

Update joins.

Drop all related joins first, then loop trought the submited joins and set the relation.

Parameters:
  • objectName (string) - name of the object
  • id (string) - id of the instance to be removed
  • join (string) - name of the join field (joinMethodName)
  • joinType (string) - type of the join (Multiple or Related)
  • joinObjectName (string) - name of the joined object (otherClassName)
  • joins (string) - coma delimited string of join instances id's

updateColumns(self, objectName, column, *_decorator__varargs, **_decorator__kwargs)

source code 

Update a column.

Toggle (and store) the state of the requested column in grid view display.

Parameters:
  • objectName (string) - name of the object
  • column (string) - name of the column to be hidden

updateColumnsJoinView(self, objectName, id, join, joinType, joinObjectName, column, *_decorator__varargs, **_decorator__kwargs)

source code 

Update column in join view.

Toggle (and store) the state of the requested column in grid view display for a join view.

Parameters:
  • objectName (string) - name of the object
  • id (string) - id of the 'parent' instance
  • join (string) - name of the join (joinMethodName in SQLObject parlance)
  • joinType (string) - name of join type
  • joinObjectName (string) - otherClassName (in SQLObject parlance)
  • column (string) - name of the column to be hidden or shown

joins(self, objectName, id, join, joinType, joinObjectName, *_decorator__varargs, **_decorator__kwargs)

source code 

Get joins.

Return a JSON structure containing a list joins for the requested object's joinMethodName.

Parameters:
  • objectName (string) - name of the object
  • id (string) - id of the instance
  • join (string) - name of the join (joinMethodName in SQLObject parlance)
  • joinType (string) - name of join type
  • joinObjectName (string) - otherClassName (in SQLObject parlance)

instance(self, objectName, id, *_decorator__varargs, **_decorator__kwargs)

source code 

Get object instance.

Return a JSON structure containing the columns and field values for the requested object

Parameters:
  • objectName (string) - name of the object
  • id (string) - id of the instance

columnsForLabel(self, objectName, foreignObjectName, foreignKeyName, *_decorator__varargs, **_decorator__kwargs)

source code 

Get columns for label.

Return a JSON structure with a list of columns to use as foreignKey label.

Parameters:
  • objectName (string) - name of the object
  • foreignObjectName (string) - name of the object the foreignKey refers to
  • foreignKeyName (string) - name of the object foreignKey field

setColumnForLabel(self, objectName, foreignObjectName, foreignKeyName, columnName, *_decorator__varargs, **_decorator__kwargs)

source code 

Set columns for label.

Exposed method that let you store the column name to be used as foreignKey label for the requested object.

Parameters:
  • objectName (string) - name of the object
  • foreignObjectName (string) - name of the object the foreignKey refers to
  • foreignKeyName (string) - name of the object foreignKey field
  • columnName (string) - name of the column to use as foreignKey label

columns(self, objectName, *_decorator__varargs, **kv)

source code 

Return JSON structure containing a list of column properties.

Parameters:
  • objectName (string) - name of the object

index(self, *_decorator__varargs, **_decorator__kwargs)

source code 

Main CatWalk page.

Import the proper client side libraries and set up the placeholder for the dynamic elements.