Bruce Wade | 1 May 2012 05:18
Picon

How would I do something like this?

<at> auth.requires_membership('Analytics' or 'Analytics Manager')
def index(): 
    return dict(message="hello from analytics.py")

--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
Bruce Wade | 1 May 2012 05:26
Picon

Re: How would I do something like this?

<at> auth.requires_membership('Analytics','Analytics Manager')


Is that the correct way? it seems to be working

On Mon, Apr 30, 2012 at 8:18 PM, Bruce Wade <bruce.wade-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
<at> auth.requires_membership('Analytics' or 'Analytics Manager')
def index(): 
    return dict(message="hello from analytics.py")

--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com



--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
Bruce Wade | 1 May 2012 05:27
Picon

Re: How would I do something like this?

Never mind it doesn't work

On Mon, Apr 30, 2012 at 8:26 PM, Bruce Wade <bruce.wade-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
<at> auth.requires_membership('Analytics','Analytics Manager')

Is that the correct way? it seems to be working


On Mon, Apr 30, 2012 at 8:18 PM, Bruce Wade <bruce.wade-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
<at> auth.requires_membership('Analytics' or 'Analytics Manager')
def index(): 
    return dict(message="hello from analytics.py")

--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com



--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com



--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
Bruce Wade | 1 May 2012 06:06
Picon

Strange import problem


applications/advertisement/modules/util.py
from gluon import *

def make_page_breadcrumbs(page_breadcrumbs_items):   
    page_breadcrumbs_items_buffer = [ DIV(SPAN("", _class="breadcrumbs-arrow"),SPAN(crumb)) for crumb in page_breadcrumbs_items ]
    return DIV(page_breadcrumbs_items_buffer)    

def make_page_title(page_title, icon):    
    return SPAN(IMG(_src=icon), H6(page_title))

class pageIcon:
    UNION = "/advertisement/static/images/union_icon_55x55.png"

controllers/union.py
def index():
    from util import make_page_title
    ...

Error:
Traceback (most recent call last):
File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py", line 205, in restricted
exec ccode in environment
File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/advertisement/controllers/union.py", line 346, in <module>
File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/globals.py", line 173, in <lambda>
self._caller = lambda f: f()
File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/tools.py", line 2575, in f
return action(*a, **b)
File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/advertisement/controllers/union.py", line 5, in index
from util import make_page_title
ImportError: cannot import name make_page_title
I have no idea why in the world this is happening, any suggestions?
--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
Bill Barry | 1 May 2012 06:36
Favicon

Re: How would I do something like this?

On Mon, Apr 30, 2012 at 8:18 PM, Bruce Wade <bruce.wade@...> wrote:
>  <at> auth.requires_membership('Analytics' or 'Analytics Manager')
> def index():
>     return dict(message="hello from analytics.py")

I am a bit new to this, but my understanding is that this is what you want.

 <at> auth.requires(auth.has_membership('Analytics') and
auth.has_membership('Analytics Manager'))

Bill

Bill Barry | 1 May 2012 06:38
Favicon

Re: How would I do something like this?

On Mon, Apr 30, 2012 at 9:36 PM, Bill Barry <bill@...> wrote:
> On Mon, Apr 30, 2012 at 8:18 PM, Bruce Wade <bruce.wade@...> wrote:
>>  <at> auth.requires_membership('Analytics' or 'Analytics Manager')
>> def index():
>>     return dict(message="hello from analytics.py")
>
> I am a bit new to this, but my understanding is that this is what you want.
>
>  <at> auth.requires(auth.has_membership('Analytics') and
> auth.has_membership('Analytics Manager'))
>
> Bill

Or more probably
 <at> auth.requires(auth.has_membership('Analytics') or
auth.has_membership('Analytics Manager'))

Bill

Annet | 1 May 2012 06:50

Re: How would I do something like this?

Hi Bruce,

I had the same problem, this is the best solution, according to Anthony (https://groups.google.com/forum/#!msg/web2py/A0z8DSZdYTo/H_1N6_4MZfEJ):

<at> auth.requires(lambda: auth.has_membership('Analytics') or auth.has_membership('Analytics Manager))

I made the groups constants, in my case:

NODE='Node Manager'
HUB='Hub Manager'


Best regards,

Annet

Annet | 1 May 2012 06:57

Re: Strange import problem

What about:

from applications.advertisement.modules.util.py import*


Annet

Keith Edmunds | 1 May 2012 07:42
Gravatar

SQLFORM.grid edit form

I have a SQLFORM.grid, and I want to add a button to the form used to edit
records (as called from the grid). Is that possible?
--

-- 
"You can have everything in life you want if you help enough other people
get what they want" - Zig Ziglar. 

Who did you help today?

Bruce Wade | 1 May 2012 08:08
Picon

Re: Re: Strange import problem

Exact same problem if I use
from applications.advertisement.modules.util.py import make_page_title


On Mon, Apr 30, 2012 at 9:57 PM, Annet <anneverme-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
What about:

from applications.advertisement.modules.util.py import*


Annet



--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com

Gmane