~leonardr/lazr.restful/use-bleedthrough

« back to all changes in this revision

Viewing changes to src/lazr/restful/docs/utils.txt

  • Committer: Leonard Richardson
  • Date: 2010-01-12 17:44:41 UTC
  • mfrom: (93.1.46 entry-traverse)
  • Revision ID: leonard.richardson@canonical.com-20100112174441-jq2a2ovya8b4hj6y
[r=flacoste] It's now possible to define two distinct web services based on the same data model.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    >>> print implementation().a_method()
76
76
    superclass result
77
77
 
78
 
 
79
 
=================================
 
78
make_identifier_safe
 
79
====================
 
80
 
 
81
LAZR provides a way of converting an arbitrary string into a similar
 
82
string that can be used as a Python identifier.
 
83
 
 
84
    >>> from lazr.restful.utils import make_identifier_safe
 
85
    >>> print make_identifier_safe("already_a_valid_IDENTIFIER_444")
 
86
    already_a_valid_IDENTIFIER_444
 
87
 
 
88
    >>> print make_identifier_safe("!starts_with_punctuation")
 
89
    _starts_with_punctuation
 
90
 
 
91
    >>> print make_identifier_safe("_!contains!pu-nc.tuation")
 
92
    __contains_pu_nc_tuation
 
93
 
 
94
    >>> print make_identifier_safe("contains\nnewline")
 
95
    contains_newline
 
96
 
 
97
    >>> print make_identifier_safe("")
 
98
    _
 
99
 
 
100
    >>> print make_identifier_safe(None)
 
101
    Traceback (most recent call last):
 
102
    ...
 
103
    ValueError: Cannot make None value identifier-safe.
 
104
 
80
105
camelcase_to_underscore_separated
81
106
=================================
82
107
 
97
122
    >>> camelcase_to_underscore_separated('_StartsWithUnderscore')
98
123
    '__starts_with_underscore'
99
124
 
100
 
==============
101
125
safe_hasattr()
102
126
==============
103
127
 
130
154
    >>> safe_hasattr(oracle, 'weather')
131
155
    False
132
156
 
133
 
============
134
157
smartquote()
135
158
============
136
159
 
155
178
    >>> smartquote('a lot of "foo"?')
156
179
    u'a lot of \u201cfoo\u201d?'
157
180
 
158
 
================
159
181
safe_js_escape()
160
182
================
161
183