Changeset 6499


Ignore:
Timestamp:
2 Jul 2011, 02:30:39 (13 years ago)
Author:
uli
Message:

More docs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py

    r6495 r6499  
    2525class AccessCode(grok.Model):
    2626    """An access code (aka PIN).
     27
     28    Implements
     29    :class:`waeup.sirp.accesscodes.interfaces.IAccessCode`. :class:`AccessCode`
     30    instances are normally part of an :class:`AccessCodeBatch` so
     31    their representation (or code) is built with the containing batch
     32    involved.
     33
     34    `batch_serial`
     35       the serial number of the new :class:`AccessCode` inside its batch.
     36
     37    `random_num`
     38       a 10-digit number representing the main part of the code.
     39
     40    :class:`AccessCode` instances normally have a representation (or
     41    code) like
     42
     43      ``APP-XXX-YYYYYYYYYY``
     44
     45    where ``APP`` is the prefix of the containing batch, ``XXX`` is
     46    the batch number and ``YYYYYYYYYY`` is the real code. The complete
     47    PIN is portal-wide unique.
     48
     49    Access code instances are far more than simple strings. They have
     50    a state, a history (so that all changes can be tracked) and a
     51    cost (given as a float number).
     52
     53    The state of an access code is something like 'used', 'disabled',
     54    etc. and determined by the workflow defined in
     55    :mod:`waeup.sirp.accesscodes.workflow`. This also means that
     56    instead of setting the status of an access code directly (you
     57    can't do that easily, and yes, that's intentionally), you have to
     58    trigger a transition (that might fail, if the transition is not
     59    allowed in terms of logic or permissions). See
     60    :mod:`waeup.sirp.accesscodes.workflow` for details.
     61
    2762    """
    2863    grok.implements(IAccessCode)
     
    3570    @property
    3671    def representation(self):
     72        """A string representation of the :class:`AccessCode`.
     73
     74        It has format ``APP-XXX-YYYYYYYYYY`` as described above.
     75        """
    3776        return '%s-%s-%s' % (
    3877            self.batch_prefix, self.batch_num, self.random_num)
     
    4079    @property
    4180    def batch(self):
     81        """The batch this :class:`AccessCode` is contained.
     82        """
    4283        return getattr(self, '__parent__', None)
    4384
    4485    @property
    4586    def batch_prefix(self):
     87        """The prefix of the batch this :class:`AccessCode` belongs to.
     88        """
    4689        if self.batch is None:
    4790            return ''
     
    5093    @property
    5194    def batch_num(self):
     95        """The number of the batch this :class:`AccessCode` belongs to. A
     96        read-only attribute.
     97        """
    5298        if self.batch is None:
    5399            return ''
     
    56102    @property
    57103    def cost(self):
     104        """A float representing the price or ``None``. A read-only attribute.
     105        """
    58106        if self.batch is None:
    59107            return None
     
    62110    @property
    63111    def state(self):
     112        """The workflow state. A read-only attribute.
     113        """
    64114        return IWorkflowState(self).getState()
    65115
Note: See TracChangeset for help on using the changeset viewer.