-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathweb2py.snippets
785 lines (783 loc) · 26.3 KB
/
web2py.snippets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
# ============================================================================
# WEB2PY SNIPPETS
# web2py.snippets is based on web2py version 1.76.3
#
# @see http://github.com/lvidarte/web2py-snippets
# @author Leonardo Vidarte <lvidarte[AT]gmail.com>
# ============================================================================
#
# For autoload set in python files (web2py):
# # vim:set filetype=python.web2py:
#
# For autoload set in html files (templates web2py):
# {{# vim:set filetype=html.web2py: }}
# ============================================================================
# COMPLETE API
# ============================================================================
#
# <url:#Container Objects>
# request, response, session, cache
#
# <url:#Navigation Functions and Objects>
# redirect, HTTP
#
# <url:#Thread safe app-level module import>
# local_import
#
# <url:#Internationalization>
# T
#
# <url:#Views Helpers>
# XML, URL, BEAUTIFY
#
# <url:#HTTP Building Objects>
# A, B, BODY, BR, CENTER, CODE, DIV, EM, EMBED, FIELDSET, FORM,
# H1, H3, H3, H4, H5, H6, HEAD, HR, HTML, IFRAME, IMG, INPUT,
# LABEL, LI, LINK, OL, UL, MENU, META, OBJECT, ON, OPTION, P, PRE,
# SCRIPT, SELECT, SPAN, STYLE, TABLE, TD, TAG, TBODY,
# TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT
#
# <url:#Validator Objects>
# IS_ALPHANUMERIC, IS_DATE, IS_DATETIME,
# IS_DATE_IN_RANGE, IS_DATETIME_IN_RANGE, IS_DECIMAL_IN_RANGE, IS_EMAIL,
# IS_EXPR, IS_FLOAT_IN_RANGE, IS_IMAGE, IS_INT_IN_RANGE, IS_IN_SET,
# IS_IPV4, IS_LENGTH, IS_LOWER, IS_MATCH, IS_EMPTY_OR, IS_NOT_EMPTY,
# IS_TIME, IS_URL, IS_UPLOAD_FILENAME, IS_LIST_OF, IS_UPPER,
# IS_SLUG, IS_STRONG, CLEANUP, CRYPT, IS_IN_DB, IS_NOT_IN_DB
#
# <url:#Database API>
# DAL, Field
#
# <url:#Database to HTML>
# SQLFORM, SQLTABLE
#
# Plus: <url:#Templates>
# ============================================================================
# Container objects
# ============================================================================
snippet request_
request.${1:vars|args|cookies|get_vars|post_vars|client|application|controller|function|folder|extension|now|env}
snippet response_
response.${1:status|headers|view|cookies|flash|title|menu}
snippet session_
session.${1:varname}
snippet cache_
cache.${1:ram|disk}
# ============================================================================
# Navigation Functions and Objects
# ============================================================================
#redirect, HTTP
snippet http_
HTTP(${1:status}, body='${2:}', ${3:**headers}){$4}
snippet redirect_
redirect(${1:location}, how=${2:303})${3}
# ============================================================================
# Thread safe app-level module import
# ============================================================================
snippet local_import_
local_import(${1:name}, reload=${2:False}, app=${3:request.application})${4}
# ============================================================================
# Internationalization
# ============================================================================
snippet t_
T('${1:message}')${2}
snippet t__
T('${1:message}', symbols={})${2}
# ============================================================================
# Views Helpers
# ============================================================================
## URL
snippet url_
URL(r=request, f='${1:index}'${2})${3}
snippet url__
URL(a=${1:None}, c=${2:None}, f=${3:None}, r=${4:None}, args=[], vars={}, anchor='', extension=None)${5}
snippet helpers_ URL
URL(a=${1:None}, c=${2:None}, f=${3:None}, r=${4:None}, args=[], vars={}, anchor='', extension=None)${5}
## XML
snippet xml_
XML(${1:text}${2})${3}
snippet xml__
XML(${1:text}, sanitize=${2:False}, permitted_tags=['a','b','blockquote','br/','i','li','ol','ul','p','cite','code','pre','img/',], allowed_attributes={'a': ['href', 'title'], 'img': ['src': 'alt'], 'blockquote': ['type']})${3}
snippet helpers_ XML
XML(${1:text}, sanitize=${2:False}, permitted_tags=['a','b','blockquote','br/','i','li','ol','ul','p','cite','code','pre','img/',], allowed_attributes={'a': ['href', 'title'], 'img': ['src': 'alt'], 'blockquote': ['type']})${3}
## BEAUTIFY
snippet beautify_
BEAUTIFY(${1:*components}${2})${3}
snippet beautify__
BEAUTIFY(${1:*components}, ${2:**attributes})${3}
snippet helpers_ BEAUTIFY
BEAUTIFY(${1:*components}, ${2:**attributes})${3}
# ============================================================================
# HTTP Building Objects
# ============================================================================
## DIV
snippet div_
DIV(${1:*components})${2}
snippet div__
DIV(${1:*components}, ${2:**attributes})${3}
snippet helpers_ DIV
DIV(${1:*components}, ${2:**attributes})${3}
## TAG
snippet tag_
TAG.${1:tag}(${2:*components})${3}
snippet tag__
TAG.${1:tag}(${2:*components}, ${3:**attributes})${4}
snippet helpers_ TAG
TAG.${1:tag}(${2:*components}, ${3:**attributes})${4}
## HTML
snippet html_
HTML(${1:*components})${2}
snippet html__
HTML(${1:*components}, ${2:**attributes}, doctype='${3:strict|transitional|frameset|html5}', lang='${4:en}')${5}
snippet helpers_ HTML
HTML(${1:*components}, ${2:**attributes}, doctype='${3:strict|transitional|frameset|html5}', lang='${4:en}')${5}
## XHTML
snippet xhtml_
XHTML(${1:*components}, ${2:**attributes})${3}
snippet xhtml__
XHTML(${1:*components}, ${2:**attributes}, doctype='${3:strict|transitional|frameset}', lang='${4:en}', xmlns='${5:http://www.w3.org/1999/xhtml}')${6}
snippet helpers_ XHTML
XHTML(${1:*components}, ${2:**attributes}, doctype='${3:strict|transitional|frameset}', lang='${4:en}', xmlns='${5:http://www.w3.org/1999/xhtml}')${6}
## HEAD
snippet head_
HEAD(${1:*components})${2}
snippet head__
HEAD(${1:*components}, ${2:**attributes})${3}
snippet helpers_ HEAD
HEAD(${1:*components}, ${2:**attributes})${3}
## TITLE
snippet title_
TITLE(${1:*components})${2}
snippet title__
TITLE(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TITLE
TITLE(${1:*components}, ${2:**attributes})${3}
## META
snippet meta_
META(${1:*components})${2}
snippet meta__
META(${1:*components}, ${2:**attributes})${3}
snippet helpers_ META
META(${1:*components}, ${2:**attributes})${3}
## LINK
snippet link_
LINK(${1:*components})${2}
snippet link__
LINK(${1:*components}, ${2:**attributes})${3}
snippet helpers_ LINK
LINK(${1:*components}, ${2:**attributes})${3}
## SCRIPT
snippet script_
SCRIPT(${1:*components})${2}
snippet script__
SCRIPT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ SCRIPT
SCRIPT(${1:*components}, ${2:**attributes})${3}
## STYLE
snippet style_
STYLE(${1:*components})${2}
snippet style__
STYLE(${1:*components}, ${2:**attributes})${3}
snippet helpers_ STYLE
STYLE(${1:*components}, ${2:**attributes})${3}
## IMG
snippet img_
IMG(${1:*components})${2}
snippet img__
IMG(${1:*components}, ${2:**attributes})${3}
snippet helpers_ IMG
IMG(${1:*components}, ${2:**attributes})${3}
## SPAN
snippet span_
SPAN(${1:*components})${2}
snippet span__
SPAN(${1:*components}, ${2:**attributes})${3}
snippet helpers_ SPAN
SPAN(${1:*components}, ${2:**attributes})${3}
## BODY
snippet body_
BODY(${1:*components})${2}
snippet body__
BODY(${1:*components}, ${2:**attributes})${3}
snippet helpers_ BODY
BODY(${1:*components}, ${2:**attributes})${3}
## H1
snippet h1_
H1(${1:*components})${2}
snippet h1__
H1(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H1
H1(${1:*components}, ${2:**attributes})${3}
## H2
snippet h2_
H2(${1:*components})${2}
snippet h2__
H2(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H2
H2(${1:*components}, ${2:**attributes})${3}
## H3
snippet h3_
H3(${1:*components})${2}
snippet h3__
H3(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H3
H3(${1:*components}, ${2:**attributes})${3}
## H4
snippet h4_
H4(${1:*components})${2}
snippet h4__
H4(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H4
H4(${1:*components}, ${2:**attributes})${3}
## H5
snippet h5_
H5(${1:*components})${2}
snippet h5__
H5(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H5
H5(${1:*components}, ${2:**attributes})${3}
## H6
snippet h6_
H6(${1:*components})${2}
snippet h6__
H6(${1:*components}, ${2:**attributes})${3}
snippet helpers_ H6
H6(${1:*components}, ${2:**attributes})${3}
## P
snippet p_
P(${1:*components})${2}
snippet p__
P(${1:*components}, ${2:**attributes})${3}
snippet helpers_ P
P(${1:*components}, ${2:**attributes})${3}
## B
snippet b_
B(${1:*components})${2}
snippet b__
B(${1:*components}, ${2:**attributes})${3}
snippet helpers_ B
B(${1:*components}, ${2:**attributes})${3}
## BR
snippet br_
BR(${1:*components})${2}
snippet br__
BR(${1:*components}, ${2:**attributes})${3}
snippet helpers_ BR
BR(${1:*components}, ${2:**attributes})${3}
## HR
snippet hr_
HR(${1:*components})${2}
snippet hr__
HR(${1:*components}, ${2:**attributes})${3}
snippet helpers_ HR
HR(${1:*components}, ${2:**attributes})${3}
## A
snippet a_
A(${1:*components})${2}
snippet a__
A(${1:*components}, ${2:**attributes})${3}
snippet helpers_ A
A(${1:*components}, ${2:**attributes})${3}
## EM
snippet em_
EM(${1:*components})${2}
snippet em__
EM(${1:*components}, ${2:**attributes})${3}
snippet helpers_ EM
EM(${1:*components}, ${2:**attributes})${3}
## EMBED
snippet embed_
EMBED(${1:*components})${2}
snippet embed__
EMBED(${1:*components}, ${2:**attributes})${3}
snippet helpers_ EMBED
EMBED(${1:*components}, ${2:**attributes})${3}
## TT
snippet tt_
TT(${1:*components})${2}
snippet tt__
TT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TT
TT(${1:*components}, ${2:**attributes})${3}
## PRE
snippet pre_
PRE(${1:*components})${2}
snippet pre__
PRE(${1:*components}, ${2:**attributes})${3}
snippet helpers_ PRE
PRE(${1:*components}, ${2:**attributes})${3}
## CENTER
snippet center_
CENTER(${1:*components})${2}
snippet center__
CENTER(${1:*components}, ${2:**attributes})${3}
snippet helpers_ CENTER
CENTER(${1:*components}, ${2:**attributes})${3}
## CODE
snippet code_
CODE(${1:*components}, language='${2:python}').xml()${3}
snippet code__
CODE(${1:*components}, language='${2:python}', link=None, counter=1, styles={}).xml()${3}
snippet helpers_ CODE
CODE(${1:*components}, language='${2:python}', link=None, counter=1, styles={}).xml()${3}
## LABEL
snippet label_
LABEL(${1:*components})${2}
snippet label__
LABEL(${1:*components}, ${2:**attributes})${3}
snippet helpers_ LABEL
LABEL(${1:*components}, ${2:**attributes})${3}
## LI
snippet li_
LI(${1:*components})${2}
snippet li__
LI(${1:*components}, ${2:**attributes})${3}
snippet helpers_ LI
LI(${1:*components}, ${2:**attributes})${3}
## UL
snippet ul_
UL(${1:*components})${2}
snippet ul__
UL(${1:*components}, ${2:**attributes})${3}
snippet helpers_ UL
UL(${1:*components}, ${2:**attributes})${3}
## OL
snippet ol_
OL(${1:*components})${2}
snippet ol__
OL(${1:*components}, ${2:**attributes})${3}
snippet helpers_ OL
OL(${1:*components}, ${2:**attributes})${3}
## TD
snippet td_
TD(${1:*components})${2}
snippet td__
TD(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TD
TD(${1:*components}, ${2:**attributes})${3}
## TH
snippet th_
TH(${1:*components})${2}
snippet th__
TH(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TH
TH(${1:*components}, ${2:**attributes})${3}
## TR
snippet tr_
TR(${1:*components})${2}
snippet tr__
TR(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TR
TR(${1:*components}, ${2:**attributes})${3}
## THEAD
snippet thead_
THEAD(${1:*components})${2}
snippet thead__
THEAD(${1:*components}, ${2:**attributes})${3}
snippet helpers_ THEAD
THEAD(${1:*components}, ${2:**attributes})${3}
## TBODY
snippet tbody_
TBODY(${1:*components})${2}
snippet tbody__
TBODY(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TBODY
TBODY(${1:*components}, ${2:**attributes})${3}
## TFOOT
snippet tfoot_
TFOOT(${1:*components})${2}
snippet tfoot__
TFOOT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TFOOT
TFOOT(${1:*components}, ${2:**attributes})${3}
## TABLE
snippet table_
TABLE(${1:*components})${2}
snippet table__
TABLE(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TABLE
TABLE(${1:*components}, ${2:**attributes})${3}
## I
snippet i_
I(${1:*components})${2}
snippet i__
I(${1:*components}, ${2:**attributes})${3}
snippet helpers_ I
I(${1:*components}, ${2:**attributes})${3}
## IFRAME
snippet iframe_
IFRAME(${1:*components})${2}
snippet iframe__
IFRAME(${1:*components}, ${2:**attributes})${3}
snippet helpers_ IFRAME
IFRAME(${1:*components}, ${2:**attributes})${3}
## INPUT
snippet input_
INPUT(${1:*components})${2}
snippet input__
INPUT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ INPUT
INPUT(${1:*components}, ${2:**attributes})${3}
## TEXTAREA
snippet textarea_
TEXTAREA(${1:*components})${2}
snippet textarea__
TEXTAREA(${1:*components}, ${2:**attributes})${3}
snippet helpers_ TEXTAREA
TEXTAREA(${1:*components}, ${2:**attributes})${3}
## OPTION
snippet option_
OPTION(${1:*components})${2}
snippet option__
OPTION(${1:*components}, ${2:**attributes})${3}
snippet helpers_ OPTION
OPTION(${1:*components}, ${2:**attributes})${3}
## OBJECT
snippet object_
OBJECT(${1:*components})${2}
snippet object__
OBJECT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ OBJECT
OBJECT(${1:*components}, ${2:**attributes})${3}
## SELECT
snippet select_
SELECT(${1:*components})${2}
snippet select__
SELECT(${1:*components}, ${2:**attributes})${3}
snippet helpers_ SELECT
SELECT(${1:*components}, ${2:**attributes})${3}
## FIELDSET
snippet fieldset_
FIELDSET(${1:*components})${2}
snippet fieldset__
FIELDSET(${1:*components}, ${2:**attributes})${3}
snippet helpers_ FIELDSET
FIELDSET(${1:*components}, ${2:**attributes})${3}
## LEGEND
snippet legend_
LEGEND(${1:*components})${2}
snippet legend__
LEGEND(${1:*components}, ${2:**attributes})${3}
snippet helpers_ LEGEND
LEGEND(${1:*components}, ${2:**attributes})${3}
## FORM
snippet form_
FORM(${1:*components})${2}
snippet form__
FORM(${1:*components}, ${2:**attributes})${3}
snippet helpers_ FORM
FORM(${1:*components}, ${2:**attributes})${3}
## MENU
snippet menu_
MENU(${1:*components})${2}
snippet menu__
MENU(${1:*components}, ${2:**attributes})${3}
snippet helpers_ MENU
MENU(${1:*components}, ${2:**attributes})${3}
# ============================================================================
# Validator Objects
# ============================================================================
## IS_ALPHANUMERIC
snippet is_alphanumeric_
IS_ALPHANUMERIC(${1})${2}
snippet is_alphanumeric__
IS_ALPHANUMERIC(error_message='${1:enter only letters, numbers, and underscore}')${2}
snippet validators_ IS_ALPHANUMERIC
IS_ALPHANUMERIC(error_message='${1:enter only letters, numbers, and underscore}')${2}
## IS_DATE
snippet is_date_
IS_DATE(${1})${2}
snippet is_date__
IS_DATE(format='${1:%Y-%m-%d}', error_message='${2:enter date as %(format)s}')${3}
snippet validators_ IS_DATE
IS_DATE(format='${1:%Y-%m-%d}', error_message='${2:enter date as %(format)s}')${3}
## IS_DATETIME
snippet is_datetime_
IS_DATETIME(${1})${2}
snippet is_datetime__
IS_DATETIME(format='${1:%Y-%m-%d %H:%M:%S}', error_message='${2:enter date and time as %(format)s}')${3}
snippet validators_ IS_DATETIME
IS_DATETIME(format='${1:%Y-%m-%d %H:%M:%S}', error_message='${2:enter date and time as %(format)s}')${3}
## IS_DATE_IN_RANGE
snippet is_date_in_range_
IS_DATE_IN_RANGE(minimun=${1:None}, maximun=${2:None}${3})${4}
snippet is_date_in_range__
IS_DATE_IN_RANGE(minimum=${1:None}, maximum=${2:None}, format='${3:%Y-%m-%d}', error_message=${4:None})${5}
snippet validators_ IS_DATE_IN_RANGE
IS_DATE_IN_RANGE(minimum=${1:None}, maximum=${2:None}, format='${3:%Y-%m-%d}', error_message=${4:None})${5}
## IS_DATETIME_IN_RANGE
snippet is_datetime_in_range_
IS_DATETIME_IN_RANGE(minimum=${1:None}, maximum=${2:None}${3})${4}
snippet is_datetime_in_range__
IS_DATETIME_IN_RANGE(minimum=${1:None}, maximum=${2:None}, format='${3:%Y-%m-%d %H:%M:%S}', error_message=${4:None})${5}
snippet validators_ IS_DATETIME_IN_RANGE
IS_DATETIME_IN_RANGE(minimum=${1:None}, maximum=${2:None}, format='${3:%Y-%m-%d %H:%M:%S}', error_message=${4:None})${5}
## IS_DECIMAL_IN_RANGE
snippet is_decimal_in_range_
IS_DECIMAL_IN_RANGE(${1:minimum}, ${2:maximum}${3})${4}
snippet is_decimal_in_range__
IS_DECIMAL_IN_RANGE(${1:minimun}, ${2:maximun}, error_message=${3:None})${4}
snippet validators_ IS_DECIMAL_IN_RANGE
IS_DECIMAL_IN_RANGE(${1:minimun}, ${2:maximun}, error_message=${3:None})${4}
## IS_EMAIL
snippet is_email_
IS_EMAIL(${1})${2}
snippet is_email__
IS_EMAIL(banned=${1:None}, forced=${2:None}, error_message='${3:enter a valid email address}')${4}
snippet validators_ IS_EMAIL
IS_EMAIL(banned=${1:None}, forced=${2:None}, error_message='${3:enter a valid email address}')${4}
## IS_EXPR
snippet is_expr_
IS_EXPR(${1:expression}${2})${3}
snippet is_expr__
IS_EXPR(${1:expression}, error_message='${2:invalid expression}')${3}
snippet validators_ IS_EXPR
IS_EXPR(${1:expression}, error_message='${2:invalid expression}')${3}
## IS_FLOAT_IN_RANGE
snippet is_float_in_range_
IS_FLOAT_IN_RANGE(${1:minimum}, ${2:maximum}${3})${4}
snippet is_float_in_range__
IS_FLOAT_IN_RANGE(${1:minimum}, ${2:maximum}, error_message=${3:None})${4}
snippet validators_ IS_FLOAT_IN_RANGE
IS_FLOAT_IN_RANGE(${1:minimum}, ${2:maximum}, error_message=${3:None})${4}
## IS_IMAGE
snippet is_image_
IS_IMAGE(${1})${2}
snippet is_image__
IS_IMAGE(extensions=('bmp','gif','jpeg','png'), maxsize=(${1:10000}, ${2:10000}), minsize=(${3:0}, ${4:0}), error_message='${5:invalid image}')${6}
snippet validators_ IS_IMAGE
IS_IMAGE(extensions=('bmp','gif','jpeg','png'), maxsize=(${1:10000}, ${2:10000}), minsize=(${3:0}, ${4:0}), error_message='${5:invalid image}')${6}
## IS_INT_IN_RANGE
snippet is_int_in_range_
IS_INT_IN_RANGE(${1})${2}
snippet is_int_in_range__
IS_INT_IN_RANGE(${1:minimum}, ${2:maximum}, error_message=${3:None})${4}
snippet validators_ IS_INT_IN_RANGE
IS_INT_IN_RANGE(${1:minimum}, ${2:maximum}, error_message=${3:None})${4}
## IS_IN_SET
snippet is_in_set_
IS_IN_SET(${1:theset}${2})${3}
snippet is_in_set__
IS_IN_SET(${1:theset}, labels=${2:None}, error_message='${3:value not allowed}', multiple=${4:False}, zero='${5}', sort=${6:False})${7}
snippet validators_ IS_IN_SET
IS_IN_SET(${1:theset}, labels=${2:None}, error_message='${3:value not allowed}', multiple=${4:False}, zero='${5}', sort=${6:False})${7}
## IS_IN_SUBSET
snippet is_in_subset_
IS_IN_SUBSET(${1:*a}, ${2:**b})${3}
snippet is_in_subset__
IS_IN_SUBSET(${1:*a}, ${2:**b})${3}
snippet validators_ IS_IN_SUBSET
IS_IN_SUBSET(${1:*a}, ${2:**b})${3}
## IS_IPV4
snippet is_ipv4_
IS_IPV4(${1})${2}
snippet is_ipv4__
IS_IPV4(minip='${1:0.0.0.0}', maxip='${2:255.255.255.255}', invert=${3:False}, is_localhost=${4:None}, is_private=${5:None}, is_automatic=${6:None}, error_message='${7:enter a valid IPv4 address}')${8}
snippet validators_ IS_IPV4
IS_IPV4(minip='${1:0.0.0.0}', maxip='${2:255.255.255.255}', invert=${3:False}, is_localhost=${4:None}, is_private=${5:None}, is_automatic=${6:None}, error_message='${7:enter a valid IPv4 address}')${8}
## IS_LENGTH
snippet is_length_
IS_LENGTH(maxsize=${1:255}, minsize=${2:0}${3})${4}
snippet is_length__
IS_LENGTH(maxsize=${1:255}, minsize=${2:0}, error_message='${3:enter from %(min)s to %(max)s characters}')${4}
snippet validators_ IS_LENGTH
IS_LENGTH(maxsize=${1:255}, minsize=${2:0}, error_message='${3:enter from %(min)s to %(max)s characters}')${4}
## IS_LOWER
snippet is_lower_
IS_LOWER()
snippet is_lower__
IS_LOWER()
snippet validators_ IS_LOWER
IS_LOWER()
## IS_MATCH
snippet is_match_
IS_MATCH(${1:expression}${2})${3}
snippet is_match__
IS_MATCH(${1:expression}, error_message='${2:invalid expression}')${3}
snippet validators_ IS_MATCH
IS_MATCH(${1:expression}, error_message='${2:invalid expression}')${3}
## IS_EMPTY_OR
snippet is_empty_or_
IS_EMPTY_OR(${1:other})${2}
snippet is_empty_or__
IS_EMPTY_OR(${1:other}, null=${2:None}, empty_regex=${3:None})${4}
snippet validators_ IS_EMPTY_OR
IS_EMPTY_OR(${1:other}, null=${2:None}, empty_regex=${3:None})${4}
## IS_NOT_EMPTY
snippet is_not_empty_
IS_NOT_EMPTY(${1})${2}
snippet is_not_empty__
IS_NOT_EMPTY(error_message='${1:enter a value}' empty_regex=${2:None})${3}
snippet validators_ IS_NOT_EMPTY
IS_NOT_EMPTY(error_message='${1:enter a value}' empty_regex=${2:None})${3}
## IS_TIME
snippet is_time_
IS_TIME(${1})${2}
snippet is_time__
IS_TIME(error_message='${1:enter time as hh:mm:ss (seconds, am, pm optional)}')${2}
snippet validators_ IS_TIME
IS_TIME(error_message='${1:enter time as hh:mm:ss (seconds, am, pm optional)}')${2}
## IS_URL
snippet is_url_
IS_URL(${1})${2}
snippet is_url__
IS_URL(error_message='${1:enter a valid URL}', mode='${2:http}', allowed_schemes=${3:None}, prepend_scheme='${4:http}')${5}
snippet validators_ IS_URL
IS_URL(error_message='${1:enter a valid URL}', mode='${2:http}', allowed_schemes=${3:None}, prepend_scheme='${4:http}')${5}
## IS_UPLOAD_FILENAME
snippet is_upload_filename_
IS_UPLOAD_FILENAME(${1})${2}
snippet is_upload_filename__
IS_UPLOAD_FILENAME(filename=${1:None}, extension=${2:None}, lastdot=${3:True}, case=${4:1}, error_message='${5:enter valid filename}')${6}
snippet validators_ IS_UPLOAD_FILENAME
IS_UPLOAD_FILENAME(filename=${1:None}, extension=${2:None}, lastdot=${3:True}, case=${4:1}, error_message='${5:enter valid filename}')${6}
## IS_LIST_OF
snippet is_list_of_
IS_LIST_OF(${1:other})${2}
snippet is_list_of__
IS_LIST_OF(${1:other})${2}
snippet validators_ IS_LIST_OF
IS_LIST_OF(${1:other})${2}
## IS_UPPER
snippet is_upper_
IS_UPPER()
snippet is_upper__
IS_UPPER()
snippet validators_ IS_UPPER
IS_UPPER()
## IS_SLUG
snippet is_slug_
IS_SLUG(${1})${2}
snippet is_slug__
IS_SLUG(maxlen=${1:80}, check=${2:False}, error_message='${3:must be slug}')${4}
snippet validators_ IS_SLUG
IS_SLUG(maxlen=${1:80}, check=${2:False}, error_message='${3:must be slug}')${4}
## IS_STRONG
snippet is_strong_
IS_STRONG(${1})${2}
snippet is_strong__
IS_STRONG(min=${1:8}, max=${2:20}, upper=${3:1}, lower=${4:1}, number=${5:1}, special=${6:1}, specials=r'~!@#$%^&*()__-=?<>,.:;{}[]|', invalid='${7: "}', error_message=${8:None})${9}
snippet validators_ IS_STRONG
IS_STRONG(min=${1:8}, max=${2:20}, upper=${3:1}, lower=${4:1}, number=${5:1}, special=${6:1}, specials=r'~!@#$%^&*()__-=?<>,.:;{}[]|', invalid='${7: "}', error_message=${8:None})${9}
## CLEANUP
snippet cleanup_
CLEANUP(${1})${2}
snippet cleanup__
CLEANUP(regex='${1:[^ \n\w]}')${2}
snippet validators_ CLEANUP
CLEANUP(regex='${1:[^ \n\w]}')${2}
## CRYPT
snippet crypt_
CRYPT()
snippet crypt__
CRYPT()
snippet validators_ CRYPT
CRYPT()
## IS_IN_DB
snippet is_in_db_
IS_IN_DB(${1})${2}
snippet is_in_db__
IS_IN_DB(key=${1:None}, digest_alg=${2:None})${3}
snippet validators_ IS_IN_DB
IS_IN_DB(key=${1:None}, digest_alg=${2:None})${3}
## IS_NOT_IN_DB
snippet is_not_in_db_
IS_NOT_IN_DB(${1:dbset}${2})${3}
snippet is_not_in_db__
IS_NOT_IN_DB(${1:dbset}, ${2:field}, error_message='${3:value already in database}', allowed_override=${4:[]})${5}
snippet validators_ IS_NOT_IN_DB
IS_NOT_IN_DB(${1:dbset}, ${2:field}, error_message='${3:value already in database}', allowed_override=${4:[]})${5}
# ============================================================================
# Database API
# ============================================================================
## DAL
snippet dal_
db = DAL('sqlite://${1:dummy}.db')${2}
snippet dal__ sqlite
db = DAL('sqlite://${1:dummy}.db', pool_size=${2:0})${3}
snippet dal__ mysql
db = DAL('mysql://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
snippet dal__ postgres
db = DAL('postgres://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
snippet dal__ oracle
db = DAL('oracle://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
snippet dal__ mssql
db = DAL('mssql://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
snippet dal__ firebird
db = DAL('firebird://${1:user}:${2:password}@${3:localhost}/${4:database}', pool_size=${5:0})${6}
## TABLES
snippet define_table_
db.define_table('${1:tablename}',${2}
#migrate=False
)
snippet define_table__
db.define_table('${1:tablename}',
Field('${2:fieldname}', '${3:string}'${4}),
Field('${5:fieldname}', '${6:string}'${7}),${8}
#migrate=False
)
## FIELD
snippet field_
Field('${1:fieldname}', '${2:string}'${3}),${4}
snippet field__
Field(
'${2:fieldname}',
type='${3:string|boolean|integer|double|text|blob|date|time|datetime|upload|password}',
length=${4:None}, required=${5:False}, default=${6:None},
notnull=${7:False}, unique=${8:False},
requires=${9:'<default>'},
label=${10:None}, comment=${11:None}, widget=${12:None},
readable=${13:True}, writable=${14:True},
uploadfolder=${15:None}, autodelete=${16:False}, authorize=${17:None},
ondelete='CASCADE', uploadfield=True, update=None, authorize=None,
autodelte=False, represent=None, compute=None
),${18}
## WIDGETS
snippet widget_
widget=SQLFORM.widgets.${1:string|text|password|integer|double|time|date|datetime|upload|boolean|blob|options|multiple|radio|checkboxes}.widget${2}
# ============================================================================
# Database to HTML
# ============================================================================
snippet sqlform_
SQLFORM(${1:table}, record=${2:None}, deletable=${3:False}${4})${5}
snippet sqlform__
SQLFORM(${1:table}, record=${2:None}, deletable=${3:False}, linkto=${4:None}, upload=${5:None}, fields=${6:None}, labels=${7:None}, col3={}, submit_button='Submit', delete_label='Check to delete:', showid=True, readonly=False, comments=True, keepopts=[], ignore_rw=False, record_id=None, ${8:**attributes})${9}
snippet sqltable_
SQLTABLE(${1:sqlrows}${2})${3}
snippet sqltable__
SQLTABLE(${1:sqlrows}, linkto=${2:None}, upload=${3:None}, orderby=${4:None}, headers={}, truncate=16, columns=None, ${5:**attributes})${6}
# ============================================================================
# Templates
# ============================================================================
snippet include_
{{include '${1:otherview}.html'}}${2}
snippet extend_
{{extend '${1:layout}.html'}}${2}
snippet __
{{=${1:varname}}}${2}
snippet ___
{{${1:code}}}${2}
snippet if_
{{if ${1:expression}:}}${2:code}{{pass}}${3}
snippet if__
{{if ${1:expression}:}}
${2:code}
{{pass}}
snippet else_
{{else:}}
snippet elif_
{{elif ${1:expression}:}}${2}
snippet for_
{{for ${1:item} in ${2:iterable}:}}${3:code}{{pass}}
snippet for__
{{for ${1:item} in ${2:iterable}:}}
${3:code}
{{pass}}
snippet pass_
{{pass}}
snippet block_
{{
${1}
}}
snippet #_
{{# ${1:comment} }}${2}