dima-ruboss4ruby 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +2 -2
- data/Manifest.txt +9 -3
- data/README.rdoc +43 -15
- data/Rakefile +9 -4
- data/app_generators/ruboss_app/USAGE +11 -2
- data/app_generators/ruboss_app/ruboss_app_generator.rb +21 -15
- data/app_generators/ruboss_app/templates/app.yaml.erb +12 -0
- data/app_generators/ruboss_app/templates/default_tasks.rake +1 -1
- data/app_generators/ruboss_app/templates/empty.txt +0 -0
- data/app_generators/ruboss_app/templates/generate.rb +1 -5
- data/app_generators/ruboss_app/templates/index.yaml +11 -0
- data/app_generators/ruboss_app/templates/mainair-app.xml +1 -1
- data/bin/ruboss-gen +18 -4
- data/generators/ruboss_config/ruboss_config_generator.rb +0 -5
- data/generators/ruboss_controller/ruboss_controller_generator.rb +15 -10
- data/generators/ruboss_controller/templates/assist.py +65 -0
- data/generators/ruboss_controller/templates/restful.py +136 -0
- data/generators/ruboss_main_app/ruboss_main_app_generator.rb +18 -4
- data/generators/ruboss_main_app/templates/main.py.erb +29 -0
- data/generators/ruboss_main_app/templates/mainapp.mxml +5 -1
- data/generators/ruboss_scaffold/ruboss_scaffold_generator.rb +77 -46
- data/generators/ruboss_scaffold/templates/controller.py.erb +27 -0
- data/generators/ruboss_scaffold/templates/model.as.erb +1 -1
- data/generators/ruboss_scaffold/templates/model.py.erb +14 -0
- data/generators/ruboss_yaml_scaffold/USAGE +42 -4
- data/generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +8 -4
- data/lib/ruboss4ruby.rb +15 -2
- data/lib/ruboss4ruby/active_foo.rb +32 -3
- data/lib/ruboss4ruby/active_record_default_methods.rb +19 -7
- data/lib/ruboss4ruby/active_record_tasks.rb +9 -3
- data/lib/ruboss4ruby/configuration.rb +32 -0
- data/lib/ruboss4ruby/datamapper_foo.rb +6 -0
- data/lib/ruboss4ruby/rails/recipes.rb +5 -3
- data/lib/ruboss4ruby/rails/swf_helper.rb +1 -0
- data/lib/ruboss4ruby/tasks.rb +5 -0
- data/rails_generators/ruboss_config/ruboss_config_generator.rb +14 -13
- data/rails_generators/ruboss_config/templates/mainair-app.xml +1 -1
- data/rails_generators/ruboss_config/templates/ruboss_tasks.rake +1 -0
- data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +2 -5
- data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +66 -62
- data/rails_generators/ruboss_scaffold/templates/model.as.erb +1 -1
- data/rails_generators/ruboss_yaml_scaffold/USAGE +38 -1
- data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +0 -5
- data/rcl-1.0.txt +0 -0
- data/rdoc/generators/template/html/jamis.rb +588 -0
- data/ruboss4ruby.gemspec +12 -12
- metadata +15 -26
data/History.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
== 1.1.
|
1
|
+
== 1.1.1 / 2009-01-09
|
2
2
|
|
3
|
-
*
|
3
|
+
* Bug fixing code generation templates so that AIR projects compile properly with Flex SDK 3.2.0
|
data/Manifest.txt
CHANGED
@@ -6,7 +6,9 @@ app_generators/ruboss_app/USAGE
|
|
6
6
|
app_generators/ruboss_app/ruboss_app_generator.rb
|
7
7
|
app_generators/ruboss_app/templates/actionscript.properties
|
8
8
|
app_generators/ruboss_app/templates/actionscriptair.properties
|
9
|
+
app_generators/ruboss_app/templates/app.yaml.erb
|
9
10
|
app_generators/ruboss_app/templates/default_tasks.rake
|
11
|
+
app_generators/ruboss_app/templates/empty.txt
|
10
12
|
app_generators/ruboss_app/templates/expressInstall.swf
|
11
13
|
app_generators/ruboss_app/templates/flex.properties
|
12
14
|
app_generators/ruboss_app/templates/generate.rb
|
@@ -17,6 +19,7 @@ app_generators/ruboss_app/templates/html-template/history/historyFrame.html
|
|
17
19
|
app_generators/ruboss_app/templates/html-template/index.template.html
|
18
20
|
app_generators/ruboss_app/templates/html-template/playerProductInstall.swf
|
19
21
|
app_generators/ruboss_app/templates/index.html.erb
|
22
|
+
app_generators/ruboss_app/templates/index.yaml
|
20
23
|
app_generators/ruboss_app/templates/mainair-app.xml
|
21
24
|
app_generators/ruboss_app/templates/mainapp-config.xml
|
22
25
|
app_generators/ruboss_app/templates/mainapp.mxml
|
@@ -29,14 +32,19 @@ generators/ruboss_config/USAGE
|
|
29
32
|
generators/ruboss_config/ruboss_config_generator.rb
|
30
33
|
generators/ruboss_controller/USAGE
|
31
34
|
generators/ruboss_controller/ruboss_controller_generator.rb
|
35
|
+
generators/ruboss_controller/templates/assist.py
|
32
36
|
generators/ruboss_controller/templates/controller.as.erb
|
37
|
+
generators/ruboss_controller/templates/restful.py
|
33
38
|
generators/ruboss_main_app/USAGE
|
34
39
|
generators/ruboss_main_app/ruboss_main_app_generator.rb
|
40
|
+
generators/ruboss_main_app/templates/main.py.erb
|
35
41
|
generators/ruboss_main_app/templates/mainapp.mxml
|
36
42
|
generators/ruboss_scaffold/USAGE
|
37
43
|
generators/ruboss_scaffold/ruboss_scaffold_generator.rb
|
38
44
|
generators/ruboss_scaffold/templates/component.mxml.erb
|
45
|
+
generators/ruboss_scaffold/templates/controller.py.erb
|
39
46
|
generators/ruboss_scaffold/templates/model.as.erb
|
47
|
+
generators/ruboss_scaffold/templates/model.py.erb
|
40
48
|
generators/ruboss_yaml_scaffold/USAGE
|
41
49
|
generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb
|
42
50
|
gpl-3.0.txt
|
@@ -85,6 +93,7 @@ rails_generators/ruboss_scaffold/templates/model.rb.erb
|
|
85
93
|
rails_generators/ruboss_yaml_scaffold/USAGE
|
86
94
|
rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb
|
87
95
|
rcl-1.0.txt
|
96
|
+
rdoc/generators/template/html/jamis.rb
|
88
97
|
ruboss4ruby.gemspec
|
89
98
|
spec/ruboss4ruby_spec.rb
|
90
99
|
spec/spec_helper.rb
|
@@ -101,9 +110,7 @@ test/rails/fixtures/projects.yml
|
|
101
110
|
test/rails/fixtures/simple_properties.yml
|
102
111
|
test/rails/fixtures/tasks.yml
|
103
112
|
test/rails/fixtures/users.yml
|
104
|
-
test/rails/helpers/controllers.log
|
105
113
|
test/rails/helpers/functional_test_helper.rb
|
106
|
-
test/rails/helpers/models.log
|
107
114
|
test/rails/helpers/test_helper.rb
|
108
115
|
test/rails/helpers/unit_test_helper.rb
|
109
116
|
test/rails/model.yml
|
@@ -115,7 +122,6 @@ test/rails/models/task.rb
|
|
115
122
|
test/rails/models/user.rb
|
116
123
|
test/rails/playing_around_in_a_console.txt
|
117
124
|
test/rails/schema.rb
|
118
|
-
test/rails/test.sqlite3
|
119
125
|
test/rails/test.swf
|
120
126
|
test/rails/test_active_foo.rb
|
121
127
|
test/rails/test_ruboss_rails_integration_functional.rb
|
data/README.rdoc
CHANGED
@@ -1,25 +1,53 @@
|
|
1
|
-
=
|
1
|
+
= Ruboss Framework Ruby Toolkit
|
2
2
|
|
3
|
-
|
3
|
+
== Description
|
4
4
|
|
5
|
-
|
5
|
+
The Ruboss Framework brings the design principles and productivity of
|
6
|
+
Rails to Flex development, and makes integration with RESTful APIs as simple as possible.
|
6
7
|
|
7
|
-
|
8
|
+
Here's some of the things you can do:
|
8
9
|
|
9
|
-
|
10
|
+
* *Create* a complete _Adobe_ _Flex_ or _AIR_ application in less than 5 minutes.
|
10
11
|
|
11
|
-
|
12
|
+
Use our lightweight Ruby-based code generation toolkit to create a fully functional
|
13
|
+
CRUD application. Simply do:
|
14
|
+
|
15
|
+
sudo gem install ruboss4ruby
|
16
|
+
|
17
|
+
And then run:
|
18
|
+
|
19
|
+
ruboss-gen -h
|
12
20
|
|
13
|
-
*
|
14
|
-
|
15
|
-
* Mr Bones (bones)
|
21
|
+
* *Integrate* with _Ruby_ _On_ _Rails_, _Merb_ or _Sinatra_ applications
|
22
|
+
that use _ActiveRecord_, _DataMapper_, _CouchRest_, _ActiveCouch_, etc.
|
16
23
|
|
17
|
-
|
24
|
+
* *Communicate* between your Flex/AIR rich client and service providers
|
25
|
+
using either _XML_ or _JSON_.
|
26
|
+
|
27
|
+
* *Persist* your data directly in Adobe AIR's _SQLite_ database or _CouchDB_
|
28
|
+
without any additional infrastructure or intermediate servers.
|
29
|
+
|
30
|
+
* *Deploy* your Ruboss application on the Google App Engine and use Google
|
31
|
+
DataStore for persistence.
|
18
32
|
|
19
|
-
|
20
|
-
* Merb 1.0+
|
21
|
-
* Sinatra
|
33
|
+
== Getting Started
|
22
34
|
|
23
|
-
|
35
|
+
For details on how to get started with the Ruboss framework refer to:
|
24
36
|
|
25
|
-
|
37
|
+
http://github.com/dima/ruboss_framework/wikis/home
|
38
|
+
|
39
|
+
http://github.com/dima/ruboss4ruby/wikis/home
|
40
|
+
|
41
|
+
== Getting Involved
|
42
|
+
|
43
|
+
Report bugs or track framework development progress:
|
44
|
+
|
45
|
+
http://ruboss.lighthouseapp.com/projects/12668-ruboss-framework/overview
|
46
|
+
|
47
|
+
Get involved with the community:
|
48
|
+
|
49
|
+
http://groups.google.com/group/ruboss-framework
|
50
|
+
|
51
|
+
== License
|
52
|
+
|
53
|
+
Copyright (c) 2008 Ruboss Technology Corporation, released under dual GPLv3 and Ruboss Commercial License
|
data/Rakefile
CHANGED
@@ -12,13 +12,13 @@ end
|
|
12
12
|
ensure_in_path 'lib'
|
13
13
|
require 'ruboss4ruby'
|
14
14
|
|
15
|
-
depend_on 'rubigen'
|
16
|
-
depend_on 'activesupport'
|
15
|
+
depend_on 'rubigen', '1.4.0'
|
16
|
+
depend_on 'activesupport', '2.0.0'
|
17
17
|
|
18
18
|
task :default => 'spec:run'
|
19
19
|
|
20
20
|
PROJ.name = 'ruboss4ruby'
|
21
|
-
PROJ.summary = 'Ruboss Framework Code Generation Engine / Rails 2.1+
|
21
|
+
PROJ.summary = 'Ruboss Framework Code Generation Engine / Rails 2.1+ Integration Support'
|
22
22
|
PROJ.authors = 'Dima Berastau'
|
23
23
|
PROJ.email = 'dima@ruboss.com'
|
24
24
|
PROJ.url = 'http://github.com/dima/ruboss4ruby/wikis'
|
@@ -26,10 +26,15 @@ PROJ.version = Ruboss4Ruby::VERSION
|
|
26
26
|
|
27
27
|
PROJ.executables = ['bin/ruboss-gen']
|
28
28
|
|
29
|
+
#PROJ.rdoc.opts << '-Tjamis'
|
30
|
+
PROJ.rdoc.exclude << %w(.txt)
|
31
|
+
PROJ.rdoc.main = 'README.rdoc'
|
32
|
+
PROJ.rdoc.dir = 'doc/api'
|
33
|
+
|
29
34
|
PROJ.readme_file = 'README.rdoc'
|
30
35
|
PROJ.rubyforge.name = 'ruboss4ruby'
|
31
36
|
|
32
|
-
PROJ.exclude << %w(.DS_Store .gitignore)
|
37
|
+
PROJ.exclude << %w(.DS_Store .gitignore .log, .sqlite3)
|
33
38
|
|
34
39
|
PROJ.spec.opts << '--color'
|
35
40
|
PROJ.test.opts << '-W1'
|
@@ -1,13 +1,22 @@
|
|
1
1
|
Description:
|
2
|
-
Generates the primary Ruboss directory structure
|
3
|
-
specific descriptor files
|
2
|
+
Generates the primary Ruboss project directory structure and sets
|
3
|
+
up Flex Builder and TextMate specific descriptor files
|
4
4
|
|
5
5
|
You can generate Flex Builder configuration for either *pure* Flex
|
6
6
|
project or an AIR project. To generate AIR configuration pass the -a
|
7
7
|
(--air) option to the generator.
|
8
|
+
|
9
|
+
You can also choose to generate a simple Google App Engine back-end
|
10
|
+
along with your Flex front-end by passing the --gae option.
|
8
11
|
|
9
12
|
Examples:
|
10
13
|
`ruboss-gen pomodo` # generates project structure and a
|
11
14
|
# default Flex app configuration.
|
12
15
|
`ruboss-gen -a pomodo` # as above but generates an AIR app
|
13
16
|
# and configuration
|
17
|
+
`ruboss-gen --gae pomodo` # generate Flex + GAE application
|
18
|
+
# configuration
|
19
|
+
|
20
|
+
Next Steps:
|
21
|
+
In your new Ruboss project folder run `ruby script/generate` for
|
22
|
+
a list of available generators.
|
@@ -14,7 +14,9 @@ class RubossAppGenerator < RubiGen::Base
|
|
14
14
|
super
|
15
15
|
usage if args.empty?
|
16
16
|
@destination_root = File.expand_path(args.shift)
|
17
|
-
|
17
|
+
|
18
|
+
@project_name, @flex_project_name, @command_controller_name,
|
19
|
+
@base_package, @base_folder = extract_names(base_name)
|
18
20
|
|
19
21
|
@use_air = options[:air_config]
|
20
22
|
if @use_air
|
@@ -31,6 +33,16 @@ class RubossAppGenerator < RubiGen::Base
|
|
31
33
|
m.directory ''
|
32
34
|
|
33
35
|
%w(script lib db bin-debug).each { |dir| m.directory dir }
|
36
|
+
|
37
|
+
if options[:gae]
|
38
|
+
m.file 'index.yaml', 'index.yaml' unless File.exist?('index.yaml')
|
39
|
+
m.template 'app.yaml.erb', 'app.yaml' unless File.exist?('app.yaml')
|
40
|
+
m.directory 'app/controllers'
|
41
|
+
m.file 'empty.txt', 'app/__init__.py'
|
42
|
+
m.file 'empty.txt', 'app/controllers/__init__.py'
|
43
|
+
m.directory 'app/models'
|
44
|
+
m.file 'empty.txt', 'app/models/__init__.py'
|
45
|
+
end
|
34
46
|
|
35
47
|
m.file 'default_tasks.rake', 'Rakefile' unless File.exist?('Rakefile')
|
36
48
|
m.file 'flex.properties', '.flexProperties'
|
@@ -71,18 +83,12 @@ class RubossAppGenerator < RubiGen::Base
|
|
71
83
|
end
|
72
84
|
|
73
85
|
protected
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
<<-EOS
|
83
|
-
Creates the skeleton for a new Ruboss app
|
84
|
-
|
85
|
-
USAGE: #{spec.name} (-a) app_name
|
86
|
-
EOS
|
87
|
-
end
|
86
|
+
def add_options!(opt)
|
87
|
+
opt.separator ''
|
88
|
+
opt.separator 'Options:'
|
89
|
+
opt.on("-a", "--air", "Configure AIR project instead of Flex. Flex is default.",
|
90
|
+
"Default: false") { |v| options[:air_config] = v }
|
91
|
+
opt.on("--gae", "Generate Google App Engine Python classes in addition to Ruboss Flex resources.",
|
92
|
+
"Default: false") { |v| options[:gae] = v }
|
93
|
+
end
|
88
94
|
end
|
File without changes
|
@@ -12,10 +12,6 @@ require 'activesupport'
|
|
12
12
|
require 'ruboss4ruby'
|
13
13
|
|
14
14
|
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
15
|
-
source = RubiGen::PathSource.new(:component,
|
16
|
-
File.join(File.expand_path('ruboss4ruby'), "generators"))
|
17
|
-
|
18
|
-
RubiGen::Base.use_component_sources!
|
19
|
-
RubiGen::Base.append_sources source
|
20
15
|
|
16
|
+
RubiGen::Base.use_component_sources!
|
21
17
|
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
indexes:
|
2
|
+
|
3
|
+
# AUTOGENERATED
|
4
|
+
|
5
|
+
# This index.yaml is automatically updated whenever the dev_appserver
|
6
|
+
# detects that a new type of query is run. If you want to manage the
|
7
|
+
# index.yaml file manually, remove the above marker line (the line
|
8
|
+
# saying "# AUTOGENERATED"). If you want to manage some indexes
|
9
|
+
# manually, move them above the marker line. The index.yaml file is
|
10
|
+
# automatically uploaded to the admin console when you next deploy
|
11
|
+
# your application using appcfg.py.
|
data/bin/ruboss-gen
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# Generates the primary Ruboss project directory structure and
|
4
|
+
# sets up Flex Builder and TextMate specific descriptor files
|
5
|
+
#
|
6
|
+
# You can generate Flex Builder configuration for either *pure* Flex
|
7
|
+
# project or an AIR project. To generate AIR configuration pass the -a
|
8
|
+
# (--air) option to the generator.
|
9
|
+
#
|
10
|
+
# Examples:
|
11
|
+
# `ruboss-gen pomodo` # generates project structure and a
|
12
|
+
# # default Flex app configuration.
|
13
|
+
# `ruboss-gen -a pomodo` # as above but generates an AIR app
|
14
|
+
# # and configuration
|
15
|
+
#
|
16
|
+
# Next Steps:
|
17
|
+
# In your new Ruboss project folder run `ruby script/generate` for
|
18
|
+
# a list of available generators.
|
19
|
+
|
3
20
|
require 'rubygems'
|
4
21
|
require 'rubigen'
|
5
22
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'ruboss4ruby')
|
@@ -10,8 +27,5 @@ if %w(-v --version).include? ARGV.first
|
|
10
27
|
end
|
11
28
|
|
12
29
|
require 'rubigen/scripts/generate'
|
13
|
-
|
14
|
-
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
|
-
RubiGen::Base.reset_sources
|
16
|
-
RubiGen::Base.append_sources source
|
30
|
+
RubiGen::Base.use_application_sources!
|
17
31
|
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'ruboss_app')
|
@@ -7,28 +7,33 @@ class RubossControllerGenerator < RubiGen::Base
|
|
7
7
|
:base_folder,
|
8
8
|
:command_controller_name,
|
9
9
|
:model_names,
|
10
|
-
:command_names
|
11
|
-
:component_names,
|
12
|
-
:use_air,
|
13
|
-
:application_tag
|
10
|
+
:command_names
|
14
11
|
|
15
12
|
def initialize(runtime_args, runtime_options = {})
|
16
13
|
super
|
17
|
-
@project_name, @flex_project_name, @command_controller_name,
|
14
|
+
@project_name, @flex_project_name, @command_controller_name,
|
15
|
+
@base_package, @base_folder = extract_names
|
18
16
|
|
19
17
|
@model_names = list_as_files("app/flex/#{base_folder}/models")
|
20
18
|
@command_names = list_as_files("app/flex/#{base_folder}/commands")
|
21
19
|
end
|
22
20
|
|
23
21
|
def manifest
|
24
|
-
record do |m|
|
22
|
+
record do |m|
|
25
23
|
m.template 'controller.as.erb', File.join("app/flex/#{base_folder}/controllers",
|
26
|
-
"#{command_controller_name}.as")
|
24
|
+
"#{command_controller_name}.as")
|
25
|
+
if options[:gae]
|
26
|
+
m.file 'restful.py', 'app/controllers/restful.py' if !File.exist?('app/controllers/restful.py')
|
27
|
+
m.file 'assist.py', 'app/models/assist.py' if !File.exist?('app/models/assist.py')
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
protected
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
def add_options!(opt)
|
34
|
+
opt.separator ''
|
35
|
+
opt.separator 'Options:'
|
36
|
+
opt.on("--gae", "Generate Google App Engine Python classes in addition to Ruboss Flex resources.",
|
37
|
+
"Default: false") { |v| options[:gae] = v }
|
38
|
+
end
|
34
39
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2008 Dima Berastau
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to
|
7
|
+
# deal in the Software without restriction, including without limitation
|
8
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9
|
+
# and/or sell copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
21
|
+
# DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
__author__ = 'Dima Berastau'
|
24
|
+
|
25
|
+
from google.appengine.ext import db
|
26
|
+
import datetime
|
27
|
+
|
28
|
+
# Some useful module methods
|
29
|
+
def all(model):
|
30
|
+
items = "".join(str(item.to_xml()) for item in model.all())
|
31
|
+
if items == "":
|
32
|
+
return '<entities type="array"/>'
|
33
|
+
else:
|
34
|
+
return '<entities kind="%s" type="array">%s</entities>' % (model.kind(), items)
|
35
|
+
|
36
|
+
def update_model_from_params(model, params):
|
37
|
+
for k, v in params.items():
|
38
|
+
if k.endswith("_id"):
|
39
|
+
if v == "":
|
40
|
+
setattr(model, k.replace("_id", ""), None)
|
41
|
+
else:
|
42
|
+
setattr(model, k.replace("_id", ""), db.Key(v))
|
43
|
+
elif hasattr(model, k):
|
44
|
+
if isinstance(getattr(model, k), bool):
|
45
|
+
if v == "false" or v == "":
|
46
|
+
setattr(model, k, False)
|
47
|
+
else:
|
48
|
+
setattr(model, k, True)
|
49
|
+
elif isinstance(getattr(model, k), float) and v != "":
|
50
|
+
setattr(model, k, float(v))
|
51
|
+
elif isinstance(getattr(model, k), int) and v != "":
|
52
|
+
setattr(model, k, int(v))
|
53
|
+
elif isinstance(getattr(model, k), datetime.datetime) and v != "":
|
54
|
+
value = datetime.datetime.strptime(v, "%Y-%m-%dT%H:%M:%S")
|
55
|
+
setattr(model, k, value)
|
56
|
+
elif isinstance(getattr(model, k), datetime.date) and v != "":
|
57
|
+
value = datetime.datetime.strptime(v, "%Y-%m-%d")
|
58
|
+
setattr(model, k, datetime.date(value.year, value.month, value.day))
|
59
|
+
elif isinstance(getattr(model, k), datetime.time) and v != "":
|
60
|
+
value = datetime.datetime.strptime(v, "%Y-%m-%dT%H:%M:%S")
|
61
|
+
setattr(model, k, datetime.time(value.hour, value.minute, value.second))
|
62
|
+
else:
|
63
|
+
setattr(model, k, v)
|
64
|
+
|
65
|
+
model.put()
|