Hello,

You can change that without changing the original source code:
http://code.gustavonarea.net/repoze.what-quickstart/#changing-attribute-names

If you're using repoze.what.plugins.quickstart:setup_sql_auth(), you can use 
the following code:
"""
# Create a dictionary for the so-called "translations":
translations = {
    # You said you didn't want the underscore
    'user_name': 'username',
}

# Then somewhere in your middleware setup...
app = setup_sql_auth(..., translations=translations, ...)

"""

Then you can try again -- and don't forget to revert any modification on the 
source code of repoze.who/what or their plugins; if there's something else 
that you don't like, it's most likely that you can change it easily.

Please let me know if it works now.

  - Gustavo.


On Friday April 17, 2009 21:09:28 karikrishni wrote:
> Thank you for quick response. I updated my repoze.what-pylons with
> latest. Now it is not giving any error but functionally, it is not
> working.
>
>
> if is_met(has_permission('admin_post')):
>             post.user_can_suspend = True
>         else:
>             post.user_can_suspend = False
>
>
> fails.. I have given the permission to the logged in user but still it
> fails. But in the ActionProtector, it works
>
> @ActionProtector(has_permission('admin_post'),cool_handlers)
> def edit(.....)
>    .........
>   .........
>
>
>
> I did few changes to the User class but this is not related to
> permission issue. I need your comment.
>
> class User(DeclarativeBase):
>     """Reasonably basic User definition. Probably would want
> additional
>     attributes.
>     """
>     __tablename__ = 'users'
>
>     id = Column(Integer(), primary_key=True)
>     #TODO: Unique constraint
>     user_name = Column(Unicode(100))
>     ............
>     ............
>    ............
>
>
>
> I added id column 'id' which is primary key. In the sample, user_name
> was primary key.
> I didn't like underscore in user_name.. I want it to be simply
> 'username'. Is recommended to do that? any side effect?
>
> Thanks
>
> On Apr 17, 11:40 pm, Gustavo Narea <[email protected]> wrote:
> > Hello,
> >
> > Those two functions were introduced in repoze.what-pylons v1.0rc4; make
> > sure you're not using an older release:
> >     easy_install -U repoze.what-pylons
> >
> > The latest stable release is v1.0.
> >
> > Please let me know if it worked for you :)
> >
> >   - Gustavo.
> >
> > On Friday April 17, 2009 20:28:51 karikrishni wrote:
> > > Hi Gustavo & Group,
> > >
> > > I could not find is_met with my latest pylons & repoze which is
> > > installed using easy_install. Am I missing something?
> > >
> > > It will be great help for me to get answer for this to hack more into
> > > pylons on my weekend :-).
> > >
> > > Thanks
> > >
> > > On Apr 15, 8:25 pm, karikrishni <[email protected]> wrote:
> > > > I imported from 'repoze.what.plugins.pylonshq import is_met' but I am
> > > > getting error 'ImportError: cannot import name is_met'.
> > > >
> > > > Thanks
> > > >
> > > > On Apr 15, 12:06 pm, karikrishni <[email protected]> wrote:
> > > > > Thanks Gustavo. This is what I am expecting.. Thanks a lot..
> > > > >
> > > > > On Apr 15, 12:04 pm, Gustavo Narea <[email protected]> wrote:
> > > > > > Hello,
> > > > > >
> > > > > > In addition to protecting your action with a predicate, you want
> > > > > > to evaluate the has_predicate inside that action -- am I right?
> > > > > >
> > > > > > If so, you can use a code like this:
> > > > > > """
> > > > > > from repoze.what.plugins.pylonshq import is_met
> > > > > >
> > > > > > # (...)
> > > > > >
> > > > > >     @ActionProtector(has_permission('post'), cool_denial_handler)
> > > > > >     def view(self, id):
> > > > > >         # ...
> > > > > >         if is_met(has_permission('whatever')):
> > > > > >             # Do something
> > > > > > """
> > > > > >
> > > > > > Please let me know if this is not what you want.
> > > > > >
> > > > > > Cheers.
> > > > > >
> > > > > > On Wednesday April 15, 2009 04:49:31 [email protected] wrote:
> > > > > > > I have a view method which needs to enable certain html for the
> > > > > > > super user  to edit/modify/unpublish the content.
> > > > > > >
> > > > > > > def view(self, id):
> > > > > > >         identity = request.environ.get('repoze.who.identity')
> > > > > > >         db_session = meta.Session()
> > > > > > >         data_model =
> > > > > > > db_session.query(model.DataModel).filter_by (id=id).first()
> > > > > > >
> > > > > > >         ??????
> > > > > > >
> > > > > > > How to check whether user has appropriate permission to enable
> > > > > > > html tags?
> > > > > > >
> > > > > > > I am successfully using decorator to protect the action like
> > > > > > > below. I want to know how to  call has_permission method?
> > > > > > >
> > > > > > > @ActionProtector(has_permission('post'), cool_denial_handler)
> > > > > > >     def edit(self, id):
> > > > > > >         db_session = meta.Session()
> > > > > > >         .....
> > > > > > >
> > > > > > > Thanks
> > > > > >
> > > > > > --
> > > > > > Gustavo Narea <xri://=Gustavo>.
> > > > > >
> > > > > > | Tech blog: =Gustavo/(+blog)/tech  ~  About me: =Gustavo/about |
> >
> > --
> > Gustavo Narea <xri://=Gustavo>.
> >
> > | Tech blog: =Gustavo/(+blog)/tech  ~  About me: =Gustavo/about |
>
> 
-- 
Gustavo Narea <xri://=Gustavo>.
| Tech blog: =Gustavo/(+blog)/tech  ~  About me: =Gustavo/about |

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to