Hello Massimo,
I got a compile error when trying your suggestion of:
routes_in = [('/sam/$client/$a/$c/$f', '/$a/$c/$f/$client')]
routes_out = [('/$a/$c/$f/$client','/sam/$client/$a/$c/$f')]
Traceback (most recent call last):
File "web2py.py", line 18, in <module>
import gluon.widget
File "/Users/mgheith/Desktop/web2py/gluon/widget.py", line 25, in <module>
import gluon.main as main
File "/Users/mgheith/Desktop/web2py/gluon/main.py", line 129, in <module>
load()
File "/Users/mgheith/Desktop/web2py/gluon/rewrite.py", line 356, in load
p[sym].append(compile_regex(*items))
File "/Users/mgheith/Desktop/web2py/gluon/rewrite.py", line 454, in
compile_regex
return (re.compile(k, re.DOTALL), v, env or {})
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py",
line 190, in compile
return _compile(pattern, flags)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py",
line 242, in _compile
raise error, v # invalid expression
sre_constants.error: redefinition of group name 'c' as group 4; was group 2
Perhaps someone can provide a working example? Thanks in advance.
On Tuesday, July 29, 2014 12:04:50 AM UTC-5, Massimo Di Pierro wrote:
>
> The problem is that fater routes_in removes the prefix web2py does not
> know any more whether you requested client1 or client2. Should the
> application be able to discriminate?
>
> 1) If not, this should be handle through apache or nginx, not via routes.
> If you want to use routes you can make one app "a" and another app "b" be a
> symbolic link to "a". Then you do:
>
> routes_in = (
>
> ('/sam/client1/a/$c/$f', '/a/$c/$f'), (
> '/sam/client2/a/$c/$f', '/b/$c/$f')
>
> )
>
> routes_out = (
>
> ('/a/$c/$f', '/sam/client1/a/$c/$f'), ('/b/$c/$f',
> '/sam/client2/a/$c/$f')
>
> )
>
> I would not recommend it.
>
> 2) if yes, you need to pass the clientX as args0:
>
> routes_in = [('/sam/$client/$a/$c/$f', '/$a/$c/$f/$client')]
> routes_out = [('/$a/$c/$f/$client','/sam/$client/$a/$c/$f')]
>
> then your app should handle request.args[0] accordingly.
>
> On Thursday, 24 July 2014 14:07:06 UTC-5, Michael Gheith wrote:
>>
>> I plan on shoving this in the app specific routes.py - so it shouldn't
>> mess with the other apps.
>>
>> I tried your code, but it didn't work as expected. You have the right
>> idea though in regards to what I'm trying to do lyn2py. I want to
>> literally shove anything in front of app/controller/function. It's just
>> going to act as a URL prefix. Then later on, I will use the request object
>> to extract this URL prefix and then change the db connection string.
>> Having the URL prefix is mandatory, compared to just simply having it as
>> args as you suggested earlier. If you can continue to help me I will buy
>> you lunch :) I think we are really close!
>>
>>
>> On Thursday, July 24, 2014 12:29:19 PM UTC-5, lyn2py wrote:
>>>
>>> I am not exactly sure I understand your question, and I don't know how
>>> your code looks like, but you could try this:
>>>
>>> routes_in = (
>>>
>>> ('/$anything/$a/$c/$f', '/$a/$c/$f/$anything')
>>>
>>> )
>>>
>>> If you are going to have multiple apps though, this routing system will
>>> most likely break, unless they all follow the same kind of routes and have
>>> the same kind of code, in which case you might want to consider making sam
>>> an app.
>>>
>>>
>>>
>>> On Friday, July 25, 2014 1:03:51 AM UTC+8, Michael Gheith wrote:
>>>>
>>>> That's a great idea lyn2py, but I expect to run multiple applications
>>>> in one web2py instance. I can't have all my applications with the name of
>>>> sam unfortunately.
>>>>
>>>> I just discovered that I can add a URL prefix of "fff" with the
>>>> following code:
>>>>
>>>> routes_in = (
>>>>
>>>> ('/fff/$a/$c/$f', '/$a/$c/$f')
>>>>
>>>> )
>>>>
>>>>
>>>> routes_out = (
>>>>
>>>> ('/$a/$c/$f', '/fff/$a/$c/$f')
>>>>
>>>> )
>>>>
>>>>
>>>> Is it possible to change fff to be variable based on the URL? If so,
>>>> how? If we can figure that out then I think my issue will be solved.
>>>> Please help!
>>>>
>>>>
>>>> On Thursday, July 24, 2014 11:37:01 AM UTC-5, lyn2py wrote:
>>>>>
>>>>> In that case,
>>>>>
>>>>> Make sam your app's name, client1 and 2 can be the functions within
>>>>> the controller, or separate controllers for each client.
>>>>>
>>>>> If they share functions, you could shift your function's logic outside
>>>>> (into a module).
>>>>>
>>>>>
>>>>>
>>>>> On Thursday, July 24, 2014 11:50:28 PM UTC+8, Michael Gheith wrote:
>>>>>>
>>>>>> Hello lyn2py,
>>>>>>
>>>>>> Thank you for your response. Unfortunately it is necessary for me to
>>>>>> have the URL prefix of /sam/<client>. I would imagine your strategy
>>>>>> would
>>>>>> work if it was possible to dynamically add a URL prefix, but I don't
>>>>>> think
>>>>>> there is a way to do that. Anyone else have any ideas? Massimo?
>>>>>>
>>>>>> Best,
>>>>>> Michael Joseph Gheith
>>>>>>
>>>>>> On Wednesday, July 23, 2014 9:22:30 PM UTC-5, lyn2py wrote:
>>>>>>>
>>>>>>> You are pointing client1 and client2 to the same representation of
>>>>>>> the routes. It won't work properly.
>>>>>>>
>>>>>>> If you have separate domains for separate clients, see
>>>>>>> scripts/autoroutes.py
>>>>>>>
>>>>>>> If you want to serve customized to different clients, you might want
>>>>>>> to do
>>>>>>>
>>>>>>> http://127.0.0.1:8000/sam/<appname>/default/index/client1
>>>>>>> http://127.0.0.1:8000/sam/<appname>/default/index/client2
>>>>>>>
>>>>>>> EDIT: No wait… what is sam doing in there… it should be:
>>>>>>>
>>>>>>> http://127.0.0.1:8000/ <http://127.0.0.1:8000/sam/>
>>>>>>> <appname>/default/index/client1
>>>>>>> http://127.0.0.1:8000/ <http://127.0.0.1:8000/sam/>
>>>>>>> <appname>/default/index/client2
>>>>>>>
>>>>>>> and have index pull request.args(0) to match to correct client
>>>>>>>
>>>>>>> On Thursday, July 24, 2014 12:41:29 AM UTC+8, Michael Gheith wrote:
>>>>>>>>
>>>>>>>> What I'm trying to do is to have my application serve 2 different
>>>>>>>> customers via URLs like the following:
>>>>>>>>
>>>>>>>> http://127.0.0.1:8000/sam/client1/<appname>/default/index
>>>>>>>> http://127.0.0.1:8000/sam/client2/<appname>/default/index
>>>>>>>>
>>>>>>>>
>>>>>>>> My routes.py looks like:
>>>>>>>>
>>>>>>>> routes_in = (
>>>>>>>>
>>>>>>>> ('/sam/client1/$a/$c/$f', '/$a/$c/$f'), (
>>>>>>>> '/sam/client2/$a/$c/$f', '/$a/$c/$f')
>>>>>>>>
>>>>>>>> )
>>>>>>>>
>>>>>>>>
>>>>>>>> routes_out = (
>>>>>>>>
>>>>>>>> ('/$a/$c/$f', '/sam/client1/$a/$c/$f'), ('/$a/$c/$f',
>>>>>>>> '/sam/client2/$a/$c/$f')
>>>>>>>>
>>>>>>>> )
>>>>>>>>
>>>>>>>>
>>>>>>>> This works great for client1. The minute I use client2 the links
>>>>>>>> use client1 mappings in the URL. I'm using the URL function for all
>>>>>>>> my
>>>>>>>> links. Any ideas what I'm doing wrong? Perhaps this is an issue with
>>>>>>>> web2py? Please advise.
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks in advance!
>>>>>>>> M.G.
>>>>>>>>
>>>>>>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.