For anyone interested in my monologue...

Function to my previous ideas,  a function as follows could handle both 
internal and external URLs.  
I also included a simple check for allowed domains:

def __component(text):
    if text and text.lower().strip().startswith('http'):
        from urlparse import urlparse               
        allowed_domains = [
                         'www.domain1.com', 
                         'www.domain2.com', 
                       ]
        if allowed_domains and not any(i in urlparse(text)[1] for i 
inallowed_domains
): 
            return H1('domain not allowed').xml()
        else:
            return LOAD(url=text, ajax=True).xml()
    else:
        items = text.split('/')
        controller, function, args = items[0], items[1], items[2:]
        return LOAD(controller, function, args=args, ajax=True).xml()

MARKMIN(mytext,url=True,extra=dict(component = lambda value: __component(
value)))

In our Markmin we can then include...

``http://www.domain1.com/app/mycont/myfunc/arg1``:component

and/or

``mycont/myfunc/arg1``:component

.  
Maybe someone has other better, or more flexibile, ideas?


On Wednesday, May 8, 2013 2:09:28 AM UTC+1, villas wrote:
>
> I can do something like this...
> mytext = """
>
> ``default/get_cms_article/4``:component
>
> """
>
> def __component(text):
>     items = text.split('/')
>     controller, function, args = items[0], items[1], items[2:]
>     return LOAD(controller, function, args=args, ajax=True).xml()
>
> MARKMIN_ENV = dict( 
>     component = lambda value: __component(value)
> )  
>
> MARKMIN(mytext,url=True,extra=MARKMIN_ENV)
>
>
> This uses LOAD.  What is recommended for loading components from other 
> domains?  I think I have used JSON for that in the past,  but maybe there 
> are other ways,  I am not sure that I am using the currently recommended 
> methods for Markmin.
>
> Thanks!
>
>
>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to