zope.authentication

Software screenshot:
zope.authentication
Software ətraflı:
Version: 4.0.0
Tarixi Upload: 20 Feb 15
Lisenziya: Pulsuz
Məşhurluq: 5

Rating: nan/5 (Total Votes: 0)

zope.authentication Zope Çərçivə istifadə üçün identifikasiyası anlayışlar müəyyən edir.
Ətraflı Documentation
Çıxış Support
Çıxış dəstək sadə interface ILogout ilə müəyyən edilir:
& Nbsp; >>> zope.authentication.interfaces ILogout idxal olan
ki, bir "Çıxış" üsulu var.
ILogout cari istifadə, biz IAuthentication adapts sadə Çıxış həyata keçirilməsi yaratmaq lazımdır göstərmək üçün ILogout bir IAuthentication komponenti uyğunlaşdırmaq üçün:
& Nbsp; >>>adapter (IAuthentication)
& Nbsp; ...implementer (ILogout)
& Nbsp; ... class SimpleLogout (obyektin):
& Nbsp; ...
& Nbsp; ... def __init __ (özünü yoxlama):
& Nbsp; ... pass
& Nbsp; ...
& Nbsp; ... def çıxış (self, sorğu):
& Nbsp; ... print 'User həyata daxil edir'
& Nbsp; >>> provideAdapter (SimpleLogout)
və bir şey bir identifikasiyası kommunal təmsil:
& Nbsp; >>>implementer (IAuthentication)
& Nbsp; ... class Authentication (obyektin):
& Nbsp; ... pass
& Nbsp; >>> İcazə = Authentication ()
Bir çıxış yerinə yetirmək üçün, biz ILogout üçün İcazə uyğunlaşdırmaq və logout 'zəng:
& Nbsp; >>> Çıxış = ILogout (İcazə)
& Nbsp; >>> logout.logout (TestRequest ())
& Nbsp; User həyata daxil edir
"NoLogout 'Adapter
sinif:
& Nbsp; >>> zope.authentication.logout idxal NoLogout dən
başqa ILogout uyarlanabilir deyil IAuthentication komponentləri üçün ILogout bir fallback provayderi kimi qeydə alına bilər. NoLogout nin çıxış metodu heç-op var:
& Nbsp; >>> NoLogout (İcazə) .logout (TestRequest ())
Çıxış User Interface
Bir identifikasiyası protokolları rəsmi çıxış bilmir, çünki o daxil olan bir istifadəçi çıxış üçün mümkün olmaya bilər. Belə hallarda, bu giriş üçün istifadəçi interfeysi təqdim etmək yersiz olardı.
Çıxış dəstək site yapılandırılabilir Çünki, Zope qeydiyyatdan zaman, site Çıxış üçün yapılandırılmış göstərir ki, adapter təmin edir:
& Nbsp; >>> zope.authentication.logout idxal LogoutSupported
Bu ILogoutSupported həyata keçirir Bu sinif sadəcə bir bayraq kimi xidmət edir:
& Nbsp; >>> zope.authentication.interfaces ILogoutSupported idxal olan
& Nbsp; >>> ILogoutSupported.implementedBy (LogoutSupported)
& Nbsp; True
& Nbsp; >>> tələb = obyekt ()
& Nbsp; >>> ILogoutSupported.providedBy (LogoutSupported (sorğu))
& Nbsp; True
Əsas şərtləri
Əsas Terms əsas mənbələri axtarmaq üçün browser interfeys dəstək üçün istifadə olunur. Onlar dəyərlər üçün ayələr və adları təmin edir. əsas şərtləri görünüşü əsas adları almaq üçün identifikasiyası kommunal istifadə edir. Bu işləri necə üzrə nümayiş etdirmək identifikasiyası kommunal yaratmaq edək:
& Nbsp; >>> sinif Principal:
& Nbsp; ... def __init __ (özünü, id adı):
& Nbsp; ... self.id, self.title = id, adı
& Nbsp; >>> zope.interface idxal icraçısı olan
& Nbsp; >>> zope.authentication.interfaces IAuthentication idxal olan
& Nbsp; >>> zope.authentication.interfaces PrincipalLookupError idxal olan
& Nbsp; >>>implementer (IAuthentication)
& Nbsp; ... class AuthUtility:
& Nbsp; ... data = {'jim: "Jim Fulton", "stephan:" Stephan Richter'}
& Nbsp; ...
& Nbsp; ... def getPrincipal (özünü, id):
& Nbsp; ... title = self.data.get (id)
& Nbsp; ... adı None deyilsə:
& Nbsp; ... qaytarılması Principal (id, adı)
& Nbsp; ... PrincipalLookupError qaldırmaq
İndi identifikasiyası kommunal yüklemek üçün lazımdır:
& Nbsp; >>> zope.component idxal provideUtility dən
& Nbsp; >>> provideUtility (AuthUtility (), IAuthentication)
Biz bu bir görünüşü yarada bilərsiniz ki, biz əsas mənbə lazımdır.
& Nbsp; >>> zope.component idxal getUtility dən
& Nbsp; >>> sinif PrincipalSource:
& Nbsp; ... def __contains __ (özünü, id):
& Nbsp; ... İcazə = getUtility (IAuthentication)
& Nbsp; ... cəhd edin:
& Nbsp; ... auth.getPrincipal (id)
& Nbsp; ... PrincipalLookupError istisna olmaqla:
& Nbsp; ... Asma qayıtmaq
& Nbsp; ... başqa:
& Nbsp; ... True qayıtmaq
İndi biz bir şərtləri görünüşü yarada bilərsiniz:
& Nbsp; >>> zope.authentication.principal idxal PrincipalTerms dən
& Nbsp; >>> şərtləri = PrincipalTerms (PrincipalSource () None)
İndi biz şərtlərin keçirmək xahiş edə bilər:
& Nbsp; >>> müddətli = terms.getTerm (stephan)
& Nbsp; >>> term.title
& Nbsp; 'Stephan Richter "
& Nbsp; >>> term.token
& Nbsp; c3RlcGhhbg__ "
Biz mövcud deyil ki, bir müddət üçün xahiş, biz bir axtarış səhv almaq:
& Nbsp; >>> terms.getTerm (bob)
& Nbsp; Traceback (ən son zəng, son):
& Nbsp; ...
& Nbsp; LookupError: bob
Biz bir mö'cüzə varsa, bunun üçün əsas id əldə edə bilərsiniz.
& Nbsp; >>> terms.getValue (c3RlcGhhbg__)
& Nbsp; 'stephan'

Yeni Bu azad nədir:

  • zope.component.nextutility uygunsuz test asılılıq qırdı.
  • (Forward-uyğunluğu zope.component 4.0.0 ilə).

  • Ekvivalent zope.component.adapter decorator ilə
  • Dəyişdirilən deprecated zope.component.adapts istifadə.

  • Ekvivalent zope.interface.implementer decorator ilə
  • Dəyişdirilən deprecated zope.interface.implements istifadə.
  • Python 2.4 və 2.5 dəstək düşdü.

tələblər

  • Python

Geliştirici digər proqram Zope Corporation and Contributors

cipher.session
cipher.session

20 Feb 15

zope.keyreference
zope.keyreference

15 Apr 15

zope.security
zope.security

12 May 15

refline.srccheck
refline.srccheck

14 Apr 15

Şərh zope.authentication

Şərhlər tapılmadı
Şərh əlavə
Images yandırın!