Changeset 2609 in products
- Timestamp:
- Jul 2, 2010 1:46:49 PM (14 years ago)
- Location:
- quintagroup.gauth/trunk/quintagroup/gauth
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.gauth/trunk/quintagroup/gauth/configure.zcml
r2603 r2609 7 7 8 8 <include package=".browser" /> 9 10 <utility11 factory=".utility.GAuthUtility" />12 9 13 10 <genericsetup:registerProfile -
quintagroup.gauth/trunk/quintagroup/gauth/interfaces.py
r2606 r2609 1 1 from zope.interface import Interface, Attribute 2 2 3 class IGAuth Interface(Interface):3 class IGAuthUtility(Interface): 4 4 """ Utility, which operate with authentication data, 5 5 stored in Google Data configlet. -
quintagroup.gauth/trunk/quintagroup/gauth/tests.py
r2608 r2609 4 4 #from zope.testing import doctestunit 5 5 #from zope.component import testing 6 from zope.component import queryUtility 7 from zope.component import getSiteManager 6 8 from Testing import ZopeTestCase as ztc 7 9 … … 15 17 16 18 import quintagroup.gauth 19 from quintagroup.gauth.interfaces import IGAuthUtility 17 20 18 21 class GauthLayer(PloneSite): … … 48 51 49 52 class TestInstall(TestCase): 53 50 54 def afterSetUp(self): 51 55 self.loginAsPortalOwner() … … 63 67 self.assert_("quintagroup.gauth" in aifs, aifs) 64 68 69 def testUtility(self): 70 lsm = getSiteManager(self.portal) 71 gauth = lsm.queryUtility(IGAuthUtility) 72 self.assert_(gauth is not None) 73 self.assert_(gauth.gconf is not None) 65 74 66 75 class TestConfiglet(FunctionalTestCase): … … 84 93 def test_update(self): 85 94 temail, tpass = "tester@test.com", "secret" 86 from quintagroup.gauth.interfaces import IGAuthInterface 87 from zope.component import queryUtility 88 gauth_util = queryUtility(IGAuthInterface) 89 gauth_util.gconf_init(self.portal, self.portal.REQUEST) 95 gauth_util = queryUtility(IGAuthUtility) 90 96 url = self.save_url + '&form.gauth_email='+temail + '&form.gauth_pass='+tpass 91 97 self.publish(url, self.basic_auth) 92 98 self.assert_(gauth_util.email == temail) 93 99 self.assert_(gauth_util.password == tpass) 94 100 95 101 96 102 def test_suite(): -
quintagroup.gauth/trunk/quintagroup/gauth/utility.py
r2608 r2609 8 8 from plone.memoize.view import memoize_contextless 9 9 10 from quintagroup.gauth.interfaces import IGAuth Interface10 from quintagroup.gauth.interfaces import IGAuthUtility 11 11 from quintagroup.gauth.browser.configlet import IGAuthConfigletSchema 12 12 … … 20 20 21 21 class GAuthUtility(object): 22 implements(IGAuth Interface)22 implements(IGAuthUtility) 23 23 24 24 gconf = None 25 26 def gconf_init(self, context, request): 27 pps = queryMultiAdapter((context, request), name="plone_portal_state") 25 26 def __init__(self, context): 27 # Bind utility to the context 28 pps = queryMultiAdapter((context, context.REQUEST), name="plone_portal_state") 28 29 self.gconf = queryAdapter(pps.portal(), IGAuthConfigletSchema) 29 30 … … 31 32 def email(self): 32 33 """ Get the email.""" 33 if not self.gconf: 34 return None 35 return self.gconf.gauth_email 34 return getattr(self.gconf, 'gauth_email', '') 36 35 37 36 @property 38 37 def password(self): 39 38 """ Get the password.""" 40 if not self.gconf: 41 return None 42 return self.gconf.gauth_pass 39 return getattr(self.gconf, 'gauth_pass', '') 43 40 44 41 … … 55 52 56 53 def __init__(self): 57 gauth_util = queryUtility(IGAuth Interface)54 gauth_util = queryUtility(IGAuthUtility) 58 55 self.service = gdata.spreadsheet.service.SpreadsheetService( 59 56 gauth_util.email, gauth_util.password)
Note: See TracChangeset
for help on using the changeset viewer.