Share and Money Management  0.16
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...
 

Private Member Functions

def _toUnicode (self, value)
 Convert any value into a unicode string. More...
 
def _toDecimal (self, value)
 Convert any value into a decimal.Decimal value. More...
 
def _checkAttrs (self, kwargs)
 Check keyword arguments for completeness, types and value ranges. More...
 
def _setAttrs (self, ignoreEmpty, kwargs)
 Update arguments (really) More...
 
def _remove (self)
 Remove current object from database store. More...
 
def _encode (self, msg, args, kwargs)
 Convert message and arguments to the default encoding. 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()

References smm.objects.SMMBaseObject._setAttrs(), and smm.objects.SMMBaseObject.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._encode().

Here is the call graph for this function:

◆ _checkAttrs()

def smm.objects.SMMBaseObject._checkAttrs (   self,
  kwargs 
)
private

Check keyword arguments for completeness, types and value ranges.

The keyword arguments will check for completeness using the arguments set.

Parameters
selfThe object instance itself
kwargsKeyword arguments
Exceptions
ValueErrorFor unknown arguments
Test:
tests.test_objects.TestObjects.test_SMMBaseObject_checkAttrs()
See also
_setAttrs()
arguments

References smm.objects.SMMBaseObject.arguments.

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

Here is the caller graph for this function:

◆ _encode()

def smm.objects.SMMBaseObject._encode (   self,
  msg,
  args,
  kwargs 
)
private

Convert message and arguments to the default encoding.

Convert the message text as well as all unicode arguments to the to the encoding given in encoding.

Note
Please use either args or kwargs. Not both together!
Parameters
selfThe object instance itself
msgMessage text
argsArgument list
kwargsKeyword arguments
Returns
The completed and encoded text
See also
encoding

References smm.objects.SMMBaseObject.encoding.

Referenced by smm.objects.SMMBaseObject.__repr__(), 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__(), and smm.objects.Config.__str__().

Here is the caller 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.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, and smm.objects.SMMBaseObject.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)

Attributes will be converted automatically. See arguments for more details. Empty unicode strings will be set to None. Leading and trailing whitespaces will be removed.

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

References smm.objects.SMMBaseObject._checkAttrs(), smm.objects.SMMBaseObject._toDecimal(), smm.objects.SMMBaseObject._toUnicode(), and smm.objects.SMMBaseObject.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()

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

Here is the caller graph for this function:

◆ _toUnicode()

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

Convert any value into a unicode string.

This function tries to convert any value into a unicode string. Character strings will be converted directly into unicode strings. Non-string types will be converted into a character string first.

Parameters
selfThe object instance itself
valueThe value
Returns
A unicode string or None
Test:
tests.test_objects.TestObjects.test_SMMBaseObject_AttributeConversion()

References smm.objects.SMMBaseObject.encoding.

Referenced by smm.objects.SMMBaseObject._setAttrs(), and gui.log.StringHandler.emit().

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(), and smm.objects.SMMBaseObject.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': 'unicode',
}

Set of argument names for keyword arguments.

This functions should contains a set of all possible arguments names which can by used as keyword arguments.

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

Attributes marked unicode or decimal will be converted to the specified type automatically.

See also
_toUnicode() and _toDecimal()

Referenced by smm.objects.SMMBaseObject._checkAttrs(), and 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

Referenced by smm.objects.SMMBaseObject._encode(), gui.log.StringHandler._toUnicode(), and smm.objects.SMMBaseObject._toUnicode().

◆ psTopic

smm.objects.SMMBaseObject.psTopic = None
static

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