johnmahugu

https://bitbucket.org/rochacbruno/tutorial-web2py-crud HAC

Apr 13th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.43 KB | None | 0 0
  1. #web2py file structure
  2.  
  3. \project
  4. README
  5. LICENSE
  6. TODO
  7. Makefile # make all and make app
  8. web2py.py # the startup script (*)
  9. parameters.py # created at startup
  10. admin.tar # the admin app (*)
  11. examples.tar # examples and documentation app (*)
  12. welcome.tar # the welcome app (entry point) (*)
  13. \gluon # the core libraries (*)
  14. \deposit # used for zip and install apps
  15. setup_app.py # used by py2app to make OSX executable
  16. setup_exe.py # used by py2app to make Winows executble
  17. wsgihandler.py # to use Gluon with mod_wsgi
  18. \dist # used by py2app, py2exe
  19. \build # used by py2app, py2exe
  20. \tests # under development stuff
  21. \docs # in progress documentation
  22. \applications # are the apps
  23. \welcome # application welcome, for example
  24. \models
  25. \views
  26. \controllers
  27. \sessions
  28. \errors
  29. \cache
  30. \static
  31. \uploads
  32. \modules
  33.  
  34.  
  35. #EWF v1.5 -> v1.6
  36. load and save .py in ascii, avoids problem with LF+CR on windows
  37. added path.join in compileapp, fixed problem with Windows compileapp
  38.  
  39. #EWF v1.6 -> v1.7
  40. in paths replace '\' with '/' to fix problem with windows paths
  41. using limitby in database administration
  42. replaced mime/miltupart with multipart/form-data to fix a windows problem
  43.  
  44. #EWF v1.7 -> Gluon v1.0
  45. Name change
  46. Improved layout.html
  47.  
  48. #Gluon v1.0 -> v1.1
  49. bug in sqlhtml with JOINS queries
  50.  
  51. #Gluon v1.1 -> v1.2
  52. fixed some typos in examples
  53. IS_IN_SET now supports labels
  54. cleanup in sql.py does not cleanup, just checks valid field and table names
  55.  
  56. #Gluon v1.3
  57. added IS_IN_DB, IS_NOT_IN_DB and updated examples accordingly
  58.  
  59. #Gluon v1.4
  60. fixed problem with IS_INT_IN_RANGE and IS_FLOAT_IN_RANGE. Now an error in a validator is reported as a ticket. Good validators should not raise Exceptions.
  61. IS_IN_DB displays "label (id)"
  62. it can upload files without extension
  63. migration is now optional (define_table has migrate=False option)
  64.  
  65. #Gluon v1.5
  66. <form> -> <form method="post"> in errors.html
  67. replace('//','////') in sub in template.py
  68.  
  69. #Gluon v1.8
  70. no more chdir (thread unsafe)
  71. no more sys.stdout (thread unsafe)
  72. response.body is StringIO()
  73. admin/default/site informs about upgrade
  74. response.locker (optional)
  75.  
  76. #Gluon v1.9
  77. allow "count(*)" in select
  78. db.execute()
  79. fixed problem with continue and return in template
  80. removed try: ... except in sql.py
  81. fixed '\t'
  82.  
  83. #Gluon v1.10
  84. fixed concurrency problems with SQLDB._instances and SQLDB._folders, now use lock
  85. now, by default, edit SQLFORMs retain uploaded files
  86.  
  87. #Gluon v1.11
  88. appadmin allows to keep or delete uploaded files
  89.  
  90. #Gluon v1.12
  91. in sql.py
  92. handles NULL values properly
  93. unicode support (data always stored in utf-8)
  94. 'date' -> datetime.date ,'time' -> datetime.time, 'datetime' -> datetime.datetime, 'boolean' -> True/False
  95. most types have default validators
  96. SQLField(...,required=True) option.
  97. SQLRows has __str__ that serializes in CSV and xml() that serializes in HTML
  98. SQLTable has import_from_csv_file(...)
  99. gluon.simplejson for AJAX
  100. in validators.py
  101. IS_IN_DB(db,..) - db can be an SQLSet or an SQLDB
  102. better error messages
  103. in admin
  104. new import/export in csv, update and delete interface.
  105. in appadmin
  106. edit form allows to keep stored encrypted password
  107. in main.py
  108. http://host not defaults to http://host/init/default/index
  109. New third party modules
  110. gluon.simplejson(.dumps, .loads)
  111. gluon.pyrtf(.dumps)
  112. gluon.rss2(.dumps)
  113.  
  114. #Gluon v1.13
  115. (this is one of the biggest revisions ever)
  116. Improved sql.py has support MySQL, cxOracle (experimental), extract, like and better testing
  117. SQLDB.tables and SQLTable.fields are now SQLCalableList objects
  118. Fixed bug with editing integer fields storing zero
  119. Admin interface now says "insert new [tablename]" and display insert, select or update properly in the title.
  120. Added a cache mechamism. Works for data, controllers, views and SQLRows.
  121. main.py now uses a request.folder absolute path when not os.name in ['nt','posix']. Seems to work on windowsce devices, except no file locking has consequences.
  122. Now you can put modules in applications/[anyapp]/modules and import them with
  123. import applications.[anyapp].modules.[module] as [module]
  124. Fixed problem with init
  125. New applications/examples/controller/global.py controller for docs.
  126.  
  127. #Gluon v1.14
  128. Fixed a bug fix in URLs
  129.  
  130. #Gluon v1.15
  131. New try:... except. in gluon/main.py for when sessions cannot be saved
  132. Now validator/formatter method allows IS_DATE('%d/%m/%Y')
  133.  
  134. #web2py v1.16
  135. yes we changed the name! Turns out Gluon was trademarked by somebody else.
  136. Although we are not infringing the trademark since this is a non-commercial
  137. product we could have run into some issues. So we have been professional
  138. and changed the name to web2py.
  139. Now SQLFORMs and FORM can have a formname and multiple forms are allowed
  140. per page.
  141. A new examples/default/index page.
  142. web2py.py instead of runme.py
  143. mysql sets utf8 encoding.
  144. input integer field values are automatically converted int().
  145.  
  146. #web2py v1.17
  147. I posted v1.16 too soon. v1.17 was released after 1h to fix some bugs.
  148.  
  149. #web2py v1.18
  150. removed vulnerability in accept_languages and session_id
  151. Minor bug fixes. Typos and cleanup cache. Textarea now clears.
  152. Support for PyAMF.
  153. T returns a class, not a string
  154. new template parser (faster?)
  155. got rid of sintaxhighlighter in favor of server side CODE
  156. fix problem with cacheondisk locking
  157. fix 'None' instead of NULL in IS_NOT_IN_DB (I think)
  158. gluon.contrib.markdown
  159. notnull and unique in SQLField now supported (tested on sqlite mysql and postgresql)
  160. Storage now has __getstate__ and __setstate__ needed for pickling.
  161. session files are now locked to make it work better with asynchronous requests
  162. cxoracle should work, apart for limitby
  163. .../examples is now mapped to .../examples/default/index etc.
  164. .../init is now mapped to .../welcome if init is not present
  165.  
  166. #web2py 1.19
  167. minor typos
  168.  
  169. #web2py 1.20
  170. new IFRAME, LABEL, FIELDSET validators
  171. P(..cr2br=True) option
  172. FORM and SQLFORM have hidden=dict(...) option for REST
  173. testing framework.
  174. improved examples pages
  175.  
  176. #web2py 1.21
  177. replaced paste.httpserver with cherrypy.wsgi server
  178. temporary sessions are no longer saved
  179. widget has [stop] button and graph
  180. logging is done by main by appfactory
  181. fixed a bug in sql belongs
  182.  
  183. #web2py 1.22-1.25
  184. fixed minor bugs, added IS_NULL_OR
  185.  
  186. #web2py 1.26
  187. added shell.py (thanks Limodou!)
  188. added memcache support
  189.  
  190. #web2py 1.27
  191. IS_NULL_OR now works will all fields
  192. admin creates paths to static files
  193. wsgiserver options are passed to HttpServer
  194. faking limitby for oracle to make appadmin work
  195. all objects inherit from object
  196. fixed bug in app names with .
  197. fixed bug in created RestrictedError object on windows
  198. shell is now in gluon and accessible via web2py.py
  199.  
  200. #web2py 1.28
  201. fixed bug with belongs, faster sql.py
  202. included jquery.js
  203. minor aestetical fixes
  204. sortable.js is gone
  205.  
  206. #web2py 1.29
  207. Now selet mutliple works with get, so does is IS_LENGTH
  208. Added IS_LIST_OF
  209. fixed problem with admin from windows and localhost
  210.  
  211. #web2py 1.30
  212. added flv to contenttype
  213. added support for appengine
  214.  
  215. #web2py 1.31-1.41
  216. some bug fixes, mostly better appengine support
  217. mssql support
  218. firebird support
  219. widgets support
  220. connection pools
  221.  
  222. #1.42
  223. fixed security issue by removing slash escape in mysql
  224. removed random everywhere
  225. use uuid for session and tickets
  226. use http_x_forward_for to figure out the client causing a ticket
  227. use longtext and longblob for mysql
  228. main now really catches all exceptions
  229. no more warnings on GAE
  230.  
  231. #1.43-1.48
  232. html.py rewrite (better support for custom forms) (Bill Ferrett)
  233. new stickers in examples (thanks Mateusz)
  234. on windows can run in taskbar (Mark Larsen)
  235. in admin|edit page link to edit|controller (Nathan Freeze)
  236. better error codes and routes_onerror (Timothy Farrell)
  237. DAL support for groupy and having
  238. DAL support for expressions instead of values
  239. DAL has experimental Informix support
  240. fixed bug with non-printable chars in DAL
  241. 'text' fields limited to 2**16 (to avoid mysql problems)
  242. widget has -quiet and -debug (Attila Csipa)
  243. web2py_session uses BLOB instead of TEXT
  244. improved IS_URL
  245. Runs with python 2.6 (Tim)
  246. On GAE uses GAE for static files (Robin)
  247.  
  248.  
  249. #1.49
  250. fixed a bug with taskbar widget, thanks Mark
  251. fixed a bug with form.latest
  252. made many DIV methods private (_)
  253.  
  254.  
  255. #1.50
  256. Fixed some bugs introduced in 1.49
  257.  
  258. #1.51
  259. Fixed more bugs introduced in 1.49 (sql _extra and html select)
  260. support for sqlite:memory:
  261.  
  262. #1.52
  263. Fixed a minor bug with _extra[key] and key not str.
  264. check for upgrade via ajax
  265.  
  266. #1.53
  267. On GAE upload data goes automatically in datastore (blob created automatically)
  268. New appadmin runs on GAE (most of it, not all)
  269. Martin Hufsky patch allow slicing of fields in DAL expressions
  270.  
  271. #1.54
  272. fixed minor bugs
  273.  
  274. #1.55?
  275. rowcount
  276. fixed bug when IS_IN_DB involved multiple fields on GAE
  277. T.set_current_languages
  278. better unittests
  279. response.custom_commit and response.custom_rollback
  280. you can next cache calls (like cache a controller that caches a select). Thanks Iceberg
  281. db(....id==None).select() no longer returns an error but an empty SQLRows on GAE
  282. db(...).delete(delete_uploads=True) and SQLFORM.accepts(....delete_uploads=True) will delete all referenced uploaded files
  283. DIV.element and DIV.update
  284. sqlrows.json()
  285. SQLFORM.widgets
  286. URL(r=request,args=0)
  287. IS_IN_DB(...,multiple=True) for Many2Many (sort of)
  288. In URL(...,f) f is url encoded
  289. In routes_in=[['a/b/c/','a/b/c/?var=value']]
  290. simplejson 2.0.7
  291.  
  292.  
  293. #1.56
  294. Consider the following table:
  295.  
  296. db.define_table('cirlce',
  297. db.Field('radius','double'),
  298. db.Field('area','double'),
  299. db.Field('modified_on','datetime'))
  300.  
  301. now you can do:
  302.  
  303. # add a comment in the forms
  304. db.circle.area.comment="(this is a comment)"
  305.  
  306. # do not show area in create/edit forms
  307. db.circle.area.writable=False
  308.  
  309. # do not show now in display forms
  310. db.circle.modified_on.readable=False
  311.  
  312. # automatically timestamp when record cretaed
  313. db.circle.modified_on.default=request.now
  314.  
  315. # automatically timestamp when record is modified
  316. db.circle.modified_on.update=request.now
  317.  
  318. # make the radius appear in bold in display and table
  319. db.circle.radius.represent=lambda value: B(value)
  320.  
  321. # make a form that automatically computes area
  322. pi=3.1415
  323. form=SQLFOM(db.circle)
  324. if form.accepts(request.vars,
  325. onvalidation=lambda form: form.vars.area=pi*form.vars.radius**2): ...
  326.  
  327. # make a create form in two possible ways:
  328. form=SQLFORM(db.circle)
  329. form=SQLFORM(db.circle,0)
  330.  
  331. # make an update form in two possible ways:
  332. form=SQLFORM(db.circle,record)
  333. form=SQLFORM(db.circle,record_id)
  334.  
  335. # make a display form in two possible ways:
  336. form=SQLFORM(db.circle,record,readonly=True)
  337. form=SQLFORM(db.circle,record_id,readonly=True)
  338.  
  339. # so now you can do...
  340.  
  341. form=SQLFORM(db.circle,request.args[-1])
  342.  
  343. and you get a create form if the URL ends in /0, you get an update
  344. form if the URL ends in /[valid_record_id]
  345.  
  346. #you can also define once for all
  347.  
  348. timestamp=SQLTable(None,'timestamp',
  349. SQLField('created_on','datetime',
  350. writable=False,
  351. default=request.now),
  352. SQLField('modified_on','datetime',
  353. writable=False,
  354. default=request.now,update=request.now))
  355.  
  356. #and use it in all your tables
  357.  
  358. db.define_table('mytable',db.Field('somefield'),timestamp)
  359.  
  360. ###
  361.  
  362. One more feature in trunk....
  363.  
  364. db.define_table('image',SQLField('file','upload'))
  365.  
  366. db.image.file.authorize=lambda row: True or False
  367.  
  368. then controller
  369. def download(): return response.download(request,db)
  370. id' is now a hidden field sqlform
  371. gql references converted to long
  372. admin login has autofocus
  373. new notation proposed by Robin, db.table[id]
  374. new UploadWidget shows images
  375. new generic.html shows request, response, session
  376. new LEGEND helper (thanks Marcus)
  377. fixed doctests in sql (thanks Robin)
  378. new notation for DB
  379.  
  380. record=db.table[id]
  381. db.table[id]=dict(...)
  382. del db.table[id]
  383.  
  384. request.env.web2py_version
  385. new class gluon.storage.Settings has lock_keys, lock_values
  386. jquery 1.3.1
  387. PEP8 compliance
  388. new examples application
  389. runs on jython (no database drivers yet, thanks Phyo)
  390. fixed bugs in tests
  391. passes all unittest but test_rewite (not sure it should pass that one)
  392.  
  393. Lots of patches from Fran Boone (about tools) and Dougla Soares de Andarde (Python 2.6 compliance, user use of hashlib instead of md5, new markdown2.py)
  394.  
  395. #1.56.1-1.56.4
  396. fixing lots of small bugs with tool and languages
  397. jquery.1.3.2
  398.  
  399. #1.57
  400. New ajax edit with keepalive (no longer logged out when editing code)
  401. Fixed conflict resolution page.
  402. Removed /user/bin/python from models/controllers
  403.  
  404. #1.58
  405. Fixed some CRON bugs
  406. Fixed a bug with new ajax edit
  407. Experimental DB2 support in DAL
  408. Customizable font size in admin edit page
  409. New welcome/models/db.py shows how to memcache sessions on GAE with MEMDB
  410. More expressive titles in admin
  411. DB2 support. Thanks Denes!
  412.  
  413. #1.59-1.60
  414. fixed lots of small bugs
  415. routes_in can filter by http_host
  416.  
  417. #1.61
  418. fixed some typos
  419. auth.add_permissions(0,....) 0 indicates group of current user
  420. crud.update has deletable=True or False
  421. fixed issue with GAE detection -> gluon.settings.web2py_runtime -> request
  422.  
  423. #1.62
  424. SQLFORMS and crud now show readble fields
  425. Better WingIDE support
  426. Languages are automatically translated
  427. T.force and lazyT works better, optional T.lazy=False
  428. gluon.storage.Messages are now translated without T
  429. if routes.py then request.env.web2py_original_uri
  430. db.table.field.isattachment = True
  431. internationalizaiton of admin by Yair
  432. admin.py by Alvaro
  433. new MENU helper
  434. new w2p file format
  435. new welcome app with auth, service and crud turned on
  436.  
  437. #1.63-1.63.4
  438. no more import gluon.
  439. support for generic.xxx
  440. simplejson can handle datetime date and time
  441.  
  442. #1.63.5
  443. You can do jQuery.noConflict() without breaking web2py_ajax
  444. Wigets can have attributes (thanks Hans)
  445. Lots of internal cleanup and better code reusage (thanks Hans)
  446.  
  447. #1.64
  448. Models 2-3 times faster (thanks Alexey)
  449. Better LDAP support
  450. Works with Jython (including sqlite and postgresql with zxJDBC):
  451.  
  452. download jython-2.5rc3.jar
  453. download qlite-jdbc-3.6.14.2.jar
  454. java -jar jython-xxx.jar
  455. export CLASSPATH=$CLASSPATH:/Users/mdipierro/jython2.5rc3/sqlite-jdbc-3.6.14.2.jar
  456. cd web2py
  457. ../jython2.5rc3/jython web2py.py
  458.  
  459. #1.64.2
  460. New IS_COMPLEX validator, thank Mr. Freeze
  461. Experimental Informix support
  462. Autologin on registration
  463.  
  464. #1.64.3
  465. Some bug fixes
  466.  
  467. #1.64.4
  468. Som bug fixes
  469. Informix Support
  470. response.render(stream)
  471. SQLFORM.factory
  472. SQLFORM.widgets.radio and SQLFORM.widgets.checkboxes
  473.  
  474. #1.65
  475. reST docstrings for Sphinx, thanks Hans
  476. gluon/conrtib/login_methods/gae_google_account.py for google CAS login on GAE, thanks Hans
  477. fixed problem with Auth and Firebird 'password' issue
  478. new auth.settings.create_user_groups
  479. tickets stored on datastore on GAE and also logged, thanks Hans
  480. imporved IS_LENGTH with max and min, thanks Mateusz
  481. improved IS_EMAIL with filters, thanks Mateusz
  482. new IS_IMAGE checks for format and size, thanks Mateusz
  483. new IS_IPV4, thanks Mateusz
  484.  
  485. #1.65.1
  486. spreadsheet
  487. shell history, thanks sherdim
  488. crontab editor, thanks Angelo
  489. gluon/contrib/login_methods/cas_auth.py (thanks Hans)
  490. DAL(...) instead of SQLDB(...)
  491. DAL('gae') instead of GQLDB()
  492. Field instead of SQLField
  493. (the old syntax still works)
  494.  
  495. #1.65.2
  496. Fixed some small auth bugs
  497. Field.store(...)
  498.  
  499. #1.65.3-10
  500. Fixed some small bugs and typos in the docstrings
  501. Fixed AMF3 support
  502.  
  503. #1.65.11
  504. Fixed a sqlhtml bug with image upload
  505.  
  506. #1.65.12
  507. lables in auth auto-translate (thanks Alvaro)
  508. better ldap_auth (thanks Fran)
  509. auth chacks locally for blocked accounts even for alternate login methods (thanks Fran)
  510.  
  511. #1.65.13
  512. request.url (thanks Jonathan)
  513. restored uploadfield_newfilename
  514. new examples layout nad logo (thanks Mateusz)
  515.  
  516. #1.66
  517. new doctypes
  518. form.vars.newfilename
  519. new HTML and XHTML helpers
  520. better IS_LENGTH
  521.  
  522. #1.67.0
  523. Python 2.4 support (again)
  524. New layout for welcome
  525. changed defauld field sizes to 512
  526. Field(uploadfolder="...")
  527. appadmin works on GAE (again, somehting got broken at some point)
  528. new wsgiserver 3.2.0 should fix recurrent broken download problems
  529.  
  530. #1.67.1
  531. Bux fixed
  532.  
  533. #1.67.2
  534. Security fix in markdown
  535.  
  536. #1.68.1
  537. New official markdown with security fix
  538. rows.first()
  539. rows.last()
  540. New cron
  541. New hindi and spanish translation
  542. cached uploads allow for progress bars (thanks AndCycle)
  543. ingres support (thanks Chris)
  544. legacy database support for db2, mssql with non-int primary keys (thanks Denes)
  545. default setting of content-type (this may cause strange behavior in old apps when downloading images)
  546. IS_UPPER and IS_LOWER works with unicode
  547. CLENUP not takes regex of allowed/now allowed chartares
  548. New rewrite.py allows dynamic routes
  549. Better error messages for IS_INT_* and IS_FLOAT_*
  550.  
  551. #1.68.2
  552. Fixing bug with admin and missing crontab
  553. Fixing bug with rewrite.load on GAE (thanks Willian Wang)
  554.  
  555. #1.69.1
  556. Fixed a bug introduced in 1.68 about inserting unicode in DAL
  557. Fixed other small bugs
  558. Better support for legacy databases (thank Denes)
  559. response.meta replaces response.author, response.keywords, response.description
  560. response.files stets dependes in plugins
  561. better admin for packing/unpacking plugins
  562. reference fiels nor evaluate to DALRef with lazy evaluation (cool, thanks Mr Freeze)
  563. can insert a record in place of a reference
  564. record[e] instead of record._extra[e] (tentatively!)
  565. record.update_record() with no args
  566. rows.find() (thanks Mr Freeze)
  567. rows.exclude()
  568. rows.sort()
  569. rows[:]
  570.  
  571. #1.70.1
  572. Fixed bug with Rows.as_list and DALRef
  573. Added Rows.as_dict (thanks Mr Freeze and Thedeus)
  574. Added request.wsgi (thanks hcvst) allows running wsgi apps under web2py and applying wegi middleware to regular web2py actions that return strings.
  575. Experimental distributed transactions between postgresql, mysql and firebird
  576. Finally local_import is here!
  577.  
  578. #1.71.1
  579. Complete rewrite of Rows
  580. renamed DALStorage->Rows, DALRef->Reference
  581. Experimental serializarion of Row and Rows (get serialized to dict and list of dict)
  582. DAL(...,folder) and template.render(content=, context=) make it more modular
  583.  
  584. #1.72.1 - 1.72.3
  585. Better support for legacy databases
  586.  
  587. #1.73.1
  588. Fixed problem with storage and comparison of Row objects
  589. Fixed problem with mail on GAE
  590. Fixed problem with T in IS_DATE(TIME) error_message and format
  591. Rows[i].delete_record()
  592. Even better support for legacy databases
  593. Experimantal support for non UTF8 encoding in DB
  594. Better IPV4 (thanks Thandeus)
  595. T.current_languages default to 'en' and new T.set_current_languages(...) (thanks Yarko)
  596. INPUT(...,hideerror=False) used to fix rare chechbox widget problem
  597. Admin allows change of admin password
  598. New gluon/contrib/populate.py
  599. Size of input/textarea set by CSS no more by jQuery (thanks Iceberg)
  600. Customizable CSV (thanks Thandeus)
  601. More bug fixed (thanks Thandeus)
  602. Better regex for template fixed Jython problem (thank Jonathan)
  603.  
  604. #1.74.1
  605. Moved to mercurial
  606. Default validators use the new define_table(....,format='...')
  607. New get_vars and post_vars compatible in 2.5 and 2.6 (thanks Tim)
  608. Major rewrite of gql.py extends DAL syntax on GAE
  609. No more *.w2p, welcome.w2p is create automatically, base apps are always upgraded
  610. export_to_csv(delimiter = ',', quotechar = '"', quoting = csv.QUOTE_MINIMAL), thanks Thadeus
Advertisement
Add Comment
Please, Sign In to add comment