Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.auth.openidrp_ext.openidrp_sreg Namespace Reference

Functions

def openidrp_sreg_modify_request
def openidrp_sreg_create_user
def openidrp_sreg_update_user
def _openidrp_sreg_extract_values

Variables

list openidrp_sreg_required = ['nickname', 'email', 'timezone']
list openidrp_sreg_optional = ['fullname', 'language']
string openidrp_sreg_username_field = 'nickname'

Function Documentation

Definition at line 55 of file openidrp_sreg.py.

00055 
00056 def _openidrp_sreg_extract_values(info):
00057     # Pull SREG data here instead of asking user
00058     sreg_resp = SRegResponse.fromSuccessResponse(info)
00059     sreg = {'nickname': '', 'email': '', 'fullname': '',
00060             'dob': '0000-00-00', 'gender': '', 'postcode': '',
00061             'country': '', 'language': '', 'timezone': ''}
00062     if sreg_resp:
00063         if sreg_resp.get('nickname'):
00064             sreg['nickname'] = sreg_resp.get('nickname')
00065         if sreg_resp.get('fullname'):
00066             sreg['fullname'] = sreg_resp.get('fullname')
00067         if sreg_resp.get('email'):
00068             sreg['email'] = sreg_resp.get('email')
00069         # Language must be a valid value
00070         # check the MoinMoin list, or restrict to first 2 chars
00071         if sreg_resp.get('language'):
00072             # convert unknown codes to 2 char format
00073             langs = i18n.wikiLanguages().items()
00074             sreg['language'] = sreg_resp.get('language')
00075             lang_found = False
00076             for lang in langs:
00077                 if lang[0] == sreg['language']:
00078                     lang_found = True
00079             if not lang_found:
00080                 if langs[sreg['language'][0:2]]:
00081                     sreg['language'] = sreg['language'][0:2]
00082         # Timezone must be converted to offset in seconds
00083         if sreg_resp.get('timezone'):
00084             user_tz = timezone(sreg_resp.get('timezone').encode('ascii'))
00085             if user_tz:
00086                 user_utcoffset = user_tz.utcoffset(datetime.utcnow())
00087                 sreg['timezone'] = user_utcoffset.days * 24 * 60 * 60 + user_utcoffset.seconds
00088             else:
00089                 sreg['timezone'] = 0
00090     return sreg
00091 

Here is the caller graph for this function:

Definition at line 36 of file openidrp_sreg.py.

00036 
00037 def openidrp_sreg_create_user(info, u, cfg):
00038     sreg = _openidrp_sreg_extract_values(info)
00039     if sreg and sreg[cfg.openidrp_sreg_username_field] != '':
00040         u.name = sreg[cfg.openidrp_sreg_username_field]
00041     return u

Here is the call graph for this function:

Definition at line 32 of file openidrp_sreg.py.

00032 
00033 def openidrp_sreg_modify_request(oidreq, cfg):
00034     oidreq.addExtension(SRegRequest(required=cfg.openidrp_sreg_required,
00035                                     optional=cfg.openidrp_sreg_optional))

Definition at line 42 of file openidrp_sreg.py.

00042 
00043 def openidrp_sreg_update_user(info, u, cfg):
00044     sreg = _openidrp_sreg_extract_values(info)
00045     if sreg:
00046         u.name = sreg[cfg.openidrp_sreg_username_field]
00047         if sreg['email'] != '':
00048             u.email = sreg['email']
00049         if sreg['language'] != '':
00050             u.language = sreg['language']
00051         if sreg['timezone'] != '':
00052             u.tz_offset = sreg['timezone']
00053         if sreg['fullname'] != '':
00054             u.fullname = sreg['fullname']

Here is the call graph for this function:


Variable Documentation

Definition at line 29 of file openidrp_sreg.py.

list MoinMoin.auth.openidrp_ext.openidrp_sreg.openidrp_sreg_required = ['nickname', 'email', 'timezone']

Definition at line 28 of file openidrp_sreg.py.

Definition at line 30 of file openidrp_sreg.py.