Developers
   Introduction to Brainwave
   Developer's Cheat Sheet
   Grid User Manual
   API Reference Guide
   Brainwave Forum
   Downloads
  Developer Support
   FAQ
   Bug Reporting
   Feature Requests
   Tech Support
  Applications
   Getting Started
   Example Applications
   Application Framework
   Idea Framework
   Iris
   Aphrodite
   Poseidon
   Cerberus

Download Free SDK

Brainwave Academy


 Home
>> Developers >> Application >> Idea Framework

Idea Framework

Idea

An Idea is like an object in the database. It contains attributes and values (just like a regular Python dictionary). However, each attribute and the value of the attribute are also Idea objects. Hence, given a single Idea, it is possible to navigate the database using the dictionary syntax without having to understand the underlying architecture.

An Idea can be used as a base class for creating your own classes. Each class you create will inherit the properties of an Idea and behave like objects in the database of that type. For example, a custom class called 'User' can be used to navigate through all the users in the database ignoring all other ideas, (without any additional syntax). Hence, using custom classes, you can limit the scope of your search. Moreover, the result type of the objects returned will be coerced to conform to the custom class you created. This allows the application developer to take a limited view of the database.

Some methods in this class can be called on the Class itself (static methods) or on Idea instances.

The Idea Object

An Idea object behaves just like a Python dictionary or an associative array as it is sometimes known in other languages. Therefore, it is iterable over the attribute names. Hence, it is possible to do:

x = Idea.find("Prateek Sureka") for attribute_name in x: attribute_value = x[attribute_name] print attribute_name, " : ", attribute_value

Function List :-

setPoseidon(x)

x: The variable reference of the Poseidon database

Sets the Poseidon database reference to Idea. This method is normally not required. Idea is set up to automatically get a reference to the database. However in certain cases, such as during debugging, it may be required to set the Poseidon instance manually.

setContext(username, password)

username: The username to be used password: The password of the user

Switches the active user in the database according to the username and password provided. This is an easy way to switch between users (or to the administrator and back) easily.

get(x)

x: The id of the meme, for which we want to find the reference.

findAll(x)

x: The name of a meme.

Returns a list of ideas which are of type 'x'. It returns a list of Idea objects.

E.g. Idea.findAll('user') This returns a list of Ideas which all have the property "is a" set to "user"

findValues(v, classObj, where)

v: The name of the attribute. classObj: Optional. A class object which should be used to conform the results. where: Optional. Reference to a function, which is applied to each result and returns True or False

Returns a list of values of the 'v' attribute of the current idea. The result is a list of classObj instances (or Idea if classObj is not provided).

This is a dynamic method and cannot be called on the class object itself.

find(n, where, isa)

n: is the name of the object isa: Optional. Only returns results which have an attribute "is a" containing this value. Another way to get the same effect would be to create a custom class of this name extending Idea.

e.g. Idea.find('socialnet', isa='application') is equivalent to Application.find('socialnet') (where Application is a custom class which extends Idea) where: Optional. A reference to a function which is applied on all the results which must return True or False. Objects for which this function returns False are not returned.

Returns a list of Idea objects.

findBy(**kwargs)

findBy takes an unlimited number of keyword arguments of the following type: attname="attvalue".

It returns a list of Idea objects, which have ALL the attnames and attvalues for the corresponding attname.

E.g. Idea.findBy(name="Prateek", city="Kolkata") will return all the Ideas which have an attribute "name" whose value is "Prateek" AND an attribute "city" whose value is "Kolkata"

findIdeas(v)

v: The attribute name to search on

Returns a list of Ideas which contain this Idea as a value for the attribute name specified in v.

e.g. Idea.find("Kolkata")[0].findIdeas("city") Returns a list of Idea objects which contain city=Kolkata.