Share and Money Management 0.18devel
Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
smm.objects.SMMBaseObject Class Reference

Base class for all database related classes. More...

Inheritance diagram for smm.objects.SMMBaseObject:

Public Member Functions

def __init__ (self, **kwargs)
 Initialise the instance and set attributes optionally. More...
 
def __repr__ (self)
 Returns the representation of this object as string. More...
 
def update (self, **kwargs)
 Update instance arguments. More...
 
def add2db (self)
 Add an object to the database. More...
 

Static Public Attributes

dictionary arguments
 Set of argument names for keyword arguments. More...
 
 encoding = sys.stdout.encoding or sys.getdefaultencoding()
 Encoding of all character strings. More...
 
 psTopic = None
 Publish Subscribe Topic for this class. More...
 
 id = None
 Unique ID for each object. More...
 

Private Member Functions

def _toDecimal (self, value)
 Convert any value into a decimal.Decimal value. More...
 
def _setAttrs (self, ignoreEmpty, **kwargs)
 Update arguments (really) More...
 
def _remove (self)
 Remove current object from database store. More...
 

Detailed Description

Base class for all database related classes.

Constructor & Destructor Documentation

◆ __init__()

def smm.objects.SMMBaseObject.__init__ (   self,
**  kwargs 
)

Initialise the instance and set attributes optionally.

This constructor creates a new object, without checking the store whether an object exists. Use the get* functions to check the store first and creates on object later.

Call add2db() to store a new created instance in the database.

Empty keyword arguments will be ignored.

Emitted Notification:
"%s.add" % self.psTopic
See also
_setAttrs()

Reimplemented in smm.objects.Transaction, and smm.objects.Watch.

References smm.objects.SMMBaseObject._setAttrs(), smm.objects.SMMBaseObject.psTopic, smm.objects.Exchange.psTopic, smm.objects.Currency.psTopic, smm.objects.Share.psTopic, smm.objects.DailyQuote.psTopic, smm.objects.Transaction.psTopic, smm.objects.Watch.psTopic, and smm.objects.Position.psTopic.

Here is the call graph for this function:

Member Function Documentation

◆ __repr__()

def smm.objects.SMMBaseObject.__repr__ (   self)

Returns the representation of this object as string.

References smm.objects.Exchange.__str__(), smm.objects.Currency.__str__(), smm.objects.Share.__str__(), smm.objects.DailyQuote.__str__(), smm.objects.Transaction.__str__(), smm.objects.Watch.__str__(), smm.objects.Position.__str__(), smm.objects.Config.__str__(), and smm.objects.SMMBaseObject.id.

Here is the call graph for this function:

◆ _remove()

def smm.objects.SMMBaseObject._remove (   self)
private

Remove current object from database store.

Note
Use this function cautiously because references from and to other objects won't be modified.
Emitted Notification:
"%s.remove" % self.psTopic
Test:
tests.test_objects.TestObjects.test_SMMBaseObject_remove()

References smm.objects.SMMBaseObject.id, smm.objects.Exchange.id, smm.objects.Currency.id, smm.objects.Share.id, smm.objects.DailyQuote.id, smm.objects.Transaction.id, smm.objects.Watch.id, smm.objects.Position.id, smm.objects.SMMBaseObject.psTopic, smm.objects.Exchange.psTopic, smm.objects.Currency.psTopic, smm.objects.Share.psTopic, smm.objects.DailyQuote.psTopic, smm.objects.Transaction.psTopic, smm.objects.Watch.psTopic, and smm.objects.Position.psTopic.

Referenced by smm.objects.Transaction.remove(), and smm.objects.Watch.remove().

Here is the caller graph for this function:

◆ _setAttrs()

def smm.objects.SMMBaseObject._setAttrs (   self,
  ignoreEmpty,
**  kwargs 
)
private

Update arguments (really)

Empty unicode strings will be set to None and trailing whitespaces will be removed.

Exceptions
ValueErrorFor unknown arguments
Parameters
selfThe object instance itself
ignoreEmptyIgnore attributes that are None or an empty string
kwargsKeyword arguments
Test:
tests.test_objects.TestObjects.test_SMMBaseObject_setAttrs()

References smm.objects.SMMBaseObject._toDecimal(), smm.objects.SMMBaseObject.arguments, smm.objects.Exchange.arguments, smm.objects.Currency.arguments, smm.objects.Share.arguments, smm.objects.DailyQuote.arguments, smm.objects.Transaction.arguments, smm.objects.Watch.arguments, smm.objects.Position.arguments, and smm.objects.Config.arguments.

Referenced by smm.objects.SMMBaseObject.__init__(), and smm.objects.SMMBaseObject.update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _toDecimal()

def smm.objects.SMMBaseObject._toDecimal (   self,
  value 
)
private

Convert any value into a decimal.Decimal value.

Parameters
selfThe object instance itself
valueThe value
Test:
tests.test_objects.TestObjects.test_SMMBaseObject_AttributeConversion_Decimal()

Referenced by smm.objects.SMMBaseObject._setAttrs().

Here is the caller graph for this function:

◆ add2db()

def smm.objects.SMMBaseObject.add2db (   self)

Add an object to the database.

See also
database.store

Referenced by smm.objects.Share.createWatch().

Here is the caller graph for this function:

◆ update()

def smm.objects.SMMBaseObject.update (   self,
**  kwargs 
)

Update instance arguments.

Empty keyword arguments are processed. It means that single data will be deleted from the database.

See also
_setAttrs()
Emitted Notification:
"%s.change" % self.psTopic

References smm.objects.SMMBaseObject._setAttrs(), smm.objects.SMMBaseObject.psTopic, smm.objects.Exchange.psTopic, smm.objects.Currency.psTopic, smm.objects.Share.psTopic, smm.objects.DailyQuote.psTopic, smm.objects.Transaction.psTopic, smm.objects.Watch.psTopic, and smm.objects.Position.psTopic.

Referenced by smm.objects.Transaction._setDetails(), and smm.objects.Watch.remove().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ arguments

dictionary smm.objects.SMMBaseObject.arguments
static
Initial value:
= {
"name",
}

Set of argument names for keyword arguments.

It should contain all attributes to store in the database.

The primary key argument (mostly id) shouldn't be part of this set, because this argument will be set by the Storm framework.

Attributes decimal will be converted to the specified type automatically.

See also
_toDecimal()
_setAttrs()

Referenced by smm.objects.SMMBaseObject._setAttrs().

◆ encoding

smm.objects.SMMBaseObject.encoding = sys.stdout.encoding or sys.getdefaultencoding()
static

Encoding of all character strings.

The default_encoding is used to convert character strings into unicode strings

Note
Use the system encoding not a hard coded encoding

◆ id

smm.objects.SMMBaseObject.id = None
static

◆ psTopic

smm.objects.SMMBaseObject.psTopic = None
static

The documentation for this class was generated from the following file: