On Wed, 29 Mar 2006 21:30:28 -0500 Jeff Watkins <[EMAIL PROTECTED]> wrote:
>
> I added the code that checks for the presence of a request and
> throws, er, raises a more descriptive exception than
> IdentityManagementNotEnabledException, because Identity might
> actually BE enabled.
>
> Basically, there's no identity provider (or you wouldn't be seeing
> an exception at all).
Yeah, but this is just with a tg-admin shell. There is no identity
provider and also no request.
It looks like line 299 was added to soprovider.py so that users could
be created from within the tg-admin shell. If I were to guess, the new
exception is no longer being caught for this case.
On my initial analysis of this thing, I found the only place that
providers were actually being created was
identity.create_default_provider(). It reads the identity.provider
config option, which will have been set by the time tg-admin shell
gives the user control (or any other time you're accessing turbogears).
Why wouldn't we try creating a default provider when there is no
request? That way the ProviderWrapper would raise an exception only if
there was no request and the tg config options weren't set. At that
point, I think it's pretty safe to say we don't know what to do. I'm
not quite sure why we need a request to be created to have a provider.
If we did this, I believe the code within _set_password for TG_User (the
stuff around line 299), wouldn't even be needed, because we'd get the
proper provider no matter what (instead of just assuming they wanted to
SqlObjectIdentityProvider).
If I'm not making myself clear, I have a diff that should explain
me better:
Index: turbogears/identity/__init__.py
===================================================================
--- turbogears/identity/__init__.py (revision 1040)
+++ turbogears/identity/__init__.py (working copy)
@@ -72,7 +72,10 @@
try:
provider= cherrypy.request.identityProvider
except AttributeError:
- provider= None
+ try:
+ provider = create_default_provider()
+ except:
+ provider= None
if provider is None:
if not request_available():
Jason
> On 29 Mar, 2006, at 7:11 pm, Jason Chu wrote:
>
> > For some reason I thought this was addressed before release.
> >
> > I'm pretty sure I'm running everything up to date.
> >
> > With a newly quickstarted project, visit and identity enabled, and
> > having run the app once (to actually create the tg_* tables, I run
> > tg-admin shell and try to create a TG_User. I'm getting this error:
> >
> >>>> TG_Group(groupId='a', displayName='a')
> > <TG_Group 1 groupId=u'a' displayName=u'a'
> > created='datetime.datetime...)'>
> >>>> TG_User(userId='a', password='a', displayName='a',
> >>>> group=TG_Group.get(1), emailAddress='a')
> > Traceback (most recent call last):
> > File "<console>", line 1, in ?
> > File "/home/jchu/coding/sqlobject/trunk/sqlobject/declarative.py",
> > line 93, in _wrapper return_value = fn(self, *args, **kwargs)
> > File "/home/jchu/coding/sqlobject/trunk/sqlobject/main.py", line
> > 1214, in __init__ self._create(id, **kw)
> > File
> > "/home/jchu/coding/sqlobject/trunk/sqlobject/inheritance/__init__.py",
> > line 302, in _create super(InheritableSQLObject, self)._create(id,
> > **kw) File "/home/jchu/coding/sqlobject/trunk/sqlobject/main.py",
> > line 1240, in _create self.set(**kw) File
> > "/home/jchu/coding/sqlobject/trunk/sqlobject/main.py", line 1106, in
> > set setattr(self, name, value) File
> > "/home/jchu/coding/turbogears/turbogears/identity/soprovider.py",
> > line 298, in _set_password hash =
> > identity.current_provider.encrypt_password(cleartext_password) File
> > "/home/jchu/coding/turbogears/turbogears/identity/__init__.py", line
> > 79, in __getattr__ raise RequestRequiredException()
> > RequestRequiredException: An attempt was made to use a facility of
> > the TurboGears Identity Management framework that relies on an
> > HTTP request
> > outside of a request.
> >
> > Just skimming the code, it looks like the provider is created by
> > calling create_default_provider. Can't we just call that when
> > initing the shell?
> >
> > Jason
>
> --
> Jeff Watkins
> http://newburyportion.com/
>
> Democracy n: A country where the newspapers are pro-American.
>
>
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "TurboGears" group. To post to this group, send email to
> [email protected] To unsubscribe from this group, send
> email to [EMAIL PROTECTED] For more options,
> visit this group at http://groups.google.com/group/turbogears
> -~----------~----~----~----~------~----~------~--~---
>
signature.asc
Description: PGP signature

