Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
icalendar.tools.UIDGenerator Class Reference

List of all members.

Public Member Functions

def rnd_string
def uid

Static Public Attributes

tuple chars = list(ascii_letters + digits)

Detailed Description

If you are too lazy to create real uid's. Notice, this doctest is disabled!

Automatic semi-random uid
>> g = UIDGenerator()
>> uid = g.uid()
>> uid.ical()
'20050109T153222-7ekDDHKcw46QlwZK@example.com'

You Should at least insert your own hostname to be more complient
>> g = UIDGenerator()
>> uid = g.uid('Example.ORG')
>> uid.ical()
'20050109T153549-NbUItOPDjQj8Ux6q@Example.ORG'

You can also insert a path or similar
>> g = UIDGenerator()
>> uid = g.uid('Example.ORG', '/path/to/content')
>> uid.ical()
'20050109T153415-/path/to/content@Example.ORG'

Definition at line 9 of file tools.py.


Member Function Documentation

def icalendar.tools.UIDGenerator.rnd_string (   self,
  length = 16 
)

Definition at line 35 of file tools.py.

00035 
00036     def rnd_string(self, length=16):
00037         "Generates a string with random characters of length"
00038         return ''.join([random.choice(self.chars) for i in range(length)])

Here is the caller graph for this function:

def icalendar.tools.UIDGenerator.uid (   self,
  host_name = 'example.com',
  unique = '' 
)
Generates a unique id consisting of:
datetime-uniquevalue@host. Like:
20050105T225746Z-HKtJMqUgdO0jDUwm@example.com

Definition at line 39 of file tools.py.

00039 
00040     def uid(self, host_name='example.com', unique=''):
00041         """
00042         Generates a unique id consisting of:
00043         datetime-uniquevalue@host. Like:
00044         20050105T225746Z-HKtJMqUgdO0jDUwm@example.com
00045         """
00046         from PropertyValues import vText, vDatetime
00047         unique = unique or self.rnd_string()
00048         return vText('%s-%s@%s' % (vDatetime.today().ical(), unique, host_name))
00049 

Here is the call graph for this function:


Member Data Documentation

tuple icalendar.tools.UIDGenerator.chars = list(ascii_letters + digits) [static]

Definition at line 33 of file tools.py.


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