On Monday, July 1, 2013 10:47:16 PM UTC+8, Ray (a.k.a. Iceberg) wrote:
>
> On Monday, July 1, 2013 7:30:51 PM UTC+8, Ray (a.k.a. Iceberg) wrote:
>>
>> Hi folks,
>>
>> I just noticed that, the auto patterns generated by dal.py's
>> parse_as_rest() are using hyphen to replace underline. This way if I have:
>>
>> db.define_table("my_table",
>> Field("my_field"),
>> )
>>
>> it will show up in auto patterns as a url like
>> "http://.../my-table/my-field".
>>
>> However this brings some inconvenience when I am writing other pieces of
>> program to access this patterns.
>>
>> So the question is, why dal.py's parse_as_rest() intentionally change all
>> underlines into hyphens? I don't think SEO consideration matters in an api.
>> So why?
>>
>> Thanks in advance.
>>
>> Regards,
>> Ray
>>
>
> Actually I am working on a generic rest api. I end up with several
> unnecessary lines of "...replace('-', '_')", in order to counteract the
> undesirable "underline to hyphen" behavior, came from dal.py's
> parse_as_rest() auto pattern. Yet I am still curious to know, why design a
> "underline to hyphen" behavior in parse_as_rest() auto pattern?
>
> Regards,
> Ray
>
I got bitten by the same problem, again. So, in short, my table looks like
this:
db.define_table("my_table",
Field("my_field"),
)
Why the auto patterns generated by parse_as_rest() ends up as something
like this (notice the hyphen)?
"/my*-*table/id/{my_table.id}",
"/my*-*table/id/{my_table.id}/:field",
and I prefer this (notice the underline):
"/my*_*table/id/{my_table.id}",
"/my*_*table/id/{my_table.id}/:field",
Any thoughts?
--
---
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.