Changeset 3388
- Timestamp:
- 03/02/10 10:26:18 (2 years ago)
- Location:
- framework/server/branches/1.2
- Files:
-
- 4 modified
-
mapfish/commands.py (modified) (7 diffs)
-
mapfish/controllers/printer.py (modified) (3 diffs)
-
mapfish/lib/protocol.py (modified) (1 diff)
-
setup.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
framework/server/branches/1.2/mapfish/commands.py
r3083 r3388 110 110 """Main command to create a mapfish controller""" 111 111 try: 112 fileOp = FileOp(source_dir=os.path.join(113 os.path.dirname(__file__), 'templates'))114 try:115 name, directory = fileOp.parse_path_name_args(self.args[0])116 except:117 raise BadCommand('No egg_info directory was found')118 119 112 # read layers.ini 120 113 config = ConfigParser() 121 114 config.read(['layers.ini']) 122 115 # check passed layer is in layers.ini 123 if not config.has_section(name): 116 sectionName = self.args[0] 117 if not config.has_section(sectionName): 124 118 raise BadCommand( 125 'There is no layer named %s in layers.ini' % name) 119 'There is no layer section named %s in layers.ini' % \ 120 sectionName) 126 121 127 122 # get layer parameters 128 singularName = config.get(name, 'singular') 129 pluralName = config.get(name, 'plural') 130 epsg = config.get(name, 'epsg') 123 singular = config.get(sectionName, 'singular') 124 plural = config.get(sectionName, 'plural') 125 epsg = config.get(sectionName, 'epsg') 126 127 fileOp = FileOp(source_dir=os.path.join( 128 os.path.dirname(__file__), 'templates')) 129 try: 130 singularName, singularDirectory = \ 131 fileOp.parse_path_name_args(singular) 132 pluralName, pluralDirectory = \ 133 fileOp.parse_path_name_args(plural) 134 except Exception, e: 135 raise BadCommand('No egg_info directory was found') 131 136 132 137 # check the name isn't the same as the package 133 138 basePkg = fileOp.find_dir('controllers', True)[0] 134 if basePkg.lower() == name.lower():139 if basePkg.lower() == pluralName.lower(): 135 140 raise BadCommand( 136 141 'Your controller name should not be the same as ' … … 138 143 139 144 # validate the name 140 name = name.replace('-', '_')145 name = pluralName.replace('-', '_') 141 146 validateName(name) 142 147 143 148 # set test file name 144 fullName = os.path.join( directory, name)149 fullName = os.path.join(pluralDirectory, name) 145 150 if not fullName.startswith(os.sep): 146 151 fullName = os.sep + fullName … … 149 154 # set template vars 150 155 modName = name 151 fullModName = os.path.join( directory, name)156 fullModName = os.path.join(pluralDirectory, name) 152 157 contrClass = util.class_name_from_module_name(name) 153 158 modelClass = util.class_name_from_module_name(singularName) 154 modelTabObj = name + '_table'155 159 156 160 # setup the controller … … 162 166 'contrClass': contrClass, 163 167 'modelClass': modelClass, 164 'modelTabObj': modelTabObj, 165 'basePkg': basePkg, 166 'epsg': epsg}) 168 'basePkg': basePkg}) 167 169 fileOp.copy_file(template='controller.py_tmpl', 168 dest=os.path.join('controllers', directory),170 dest=os.path.join('controllers', pluralDirectory), 169 171 filename=name, 170 172 template_renderer=paste_script_template_renderer) … … 179 181 resource_command += ("config/routing.py file in the CUSTOM ROUTES section " 180 182 "like this:\n\n") 181 command = 'map.resource("%s", "%s")\n' % \ 182 (singularName, pluralName) 183 resource_command += command 183 resource_command += 'map.resource("%s", "%s")\n' % \ 184 (singularName, pluralName) 184 185 185 186 print resource_command … … 223 224 """Main command to create mapfish model""" 224 225 try: 225 fileOp = FileOp(source_dir=os.path.join(226 os.path.dirname(__file__), 'templates'))227 try:228 name, directory = fileOp.parse_path_name_args(self.args[0])229 except:230 raise BadCommand('No egg_info directory was found')231 232 226 # read layers.ini 233 227 config = ConfigParser() 234 228 config.read(['layers.ini']) 235 229 # check passed layer is in layers.ini 236 if not config.has_section(name): 230 sectionName = self.args[0] 231 if not config.has_section(sectionName): 237 232 raise BadCommand( 238 'There is no layer named %s in layers.ini' % name) 233 'There is no layer section named %s in layers.ini' % \ 234 sectionName) 239 235 240 236 # get layer parameters 241 singularName = config.get(name, 'singular') 242 table = config.get(name, 'table') 243 epsg = config.get(name, 'epsg') 244 geomColName = config.get(name, 'geomcolumn') 245 if config.has_option(name, 'schema'): 246 schema = config.get(name, 'schema') 237 singular = config.get(sectionName, 'singular') 238 plural = config.get(sectionName, 'plural') 239 table = config.get(sectionName, 'table') 240 epsg = config.get(sectionName, 'epsg') 241 geomColName = config.get(sectionName, 'geomcolumn') 242 if config.has_option(sectionName, 'schema'): 243 schema = config.get(sectionName, 'schema') 247 244 else: 248 245 schema = None 249 246 247 fileOp = FileOp(source_dir=os.path.join( 248 os.path.dirname(__file__), 'templates')) 249 try: 250 singularName, singularDirectory = \ 251 fileOp.parse_path_name_args(singular) 252 pluralName, pluralDirectory = \ 253 fileOp.parse_path_name_args(plural) 254 except: 255 raise BadCommand('No egg_info directory was found') 256 250 257 # check the name isn't the same as the package 251 basePkg = fileOp.find_dir(' controllers', True)[0]252 if basePkg.lower() == name.lower():258 basePkg = fileOp.find_dir('model', True)[0] 259 if basePkg.lower() == pluralName.lower(): 253 260 raise BadCommand( 254 'Your controllername should not be the same as '261 'Your model name should not be the same as ' 255 262 'the package name %s' % basePkg) 256 263 257 264 # validate the name 258 name = name.replace('-', '_')265 name = pluralName.replace('-', '_') 259 266 validateName(name) 260 267 … … 273 280 'schema': schema}) 274 281 fileOp.copy_file(template='model.py_tmpl', 275 dest=os.path.join('model', directory),282 dest=os.path.join('model', pluralDirectory), 276 283 filename=name, 277 284 template_renderer=paste_script_template_renderer) -
framework/server/branches/1.2/mapfish/controllers/printer.py
r3083 r3388 28 28 import simplejson 29 29 30 from routes import url_for31 30 from pylons.controllers import WSGIController 32 from pylons import config, request, response, session 31 from pylons import config, request, response, session, url 33 32 from pylons.controllers.util import forward 34 33 … … 74 73 if ret == 0: 75 74 response.status = 200 76 response.headers['Content-Type'] = 'application/json; charset=utf-8'77 75 result = self._addURLs(result) 78 76 if request.params.has_key('var'): 77 response.headers['Content-Type'] = 'text/javascript; charset=utf-8' 79 78 return 'var ' + request.params['var'].encode('utf8') + '=' + result + ';' 80 79 else: 80 response.headers['Content-Type'] = 'application/json; charset=utf-8' 81 81 return result 82 82 else: … … 206 206 actions of this controller. 207 207 """ 208 actionUrl = url _for(action = actionName, id =id)208 actionUrl = url(controller="printer", action=actionName, id=id) 209 209 if request.params.has_key('url'): 210 210 fullUrl = request.params['url'].encode('utf8') 211 myUrl = url _for(action =fromAction)211 myUrl = url(controller="printer", action=fromAction) 212 212 if fullUrl == myUrl[1:]: # support for very short relative URLs 213 213 return actionUrl[1:] -
framework/server/branches/1.2/mapfish/lib/protocol.py
r3083 r3388 349 349 if obj is None: 350 350 obj = self.mapped_class() 351 obj.geometry = asShape(feature.geometry)352 351 create = True 352 obj.geometry = asShape(feature.geometry) 353 353 for key in feature.properties: 354 354 obj[key] = feature.properties[key] -
framework/server/branches/1.2/setup.py
r3103 r3388 43 43 44 44 setup(name = 'mapfish', 45 version = '1.2 ',45 version = '1.2.1', 46 46 license = 'LGPLv3', 47 47 install_requires = requirements, … … 54 54 description = 'The MapFish web-mapping framework.', 55 55 classifiers = [ 56 'Development Status :: 3 - Alpha',56 'Development Status :: 4 - Beta', 57 57 'Intended Audience :: Developers', 58 58 'Intended Audience :: Science/Research', … … 60 60 'Operating System :: OS Independent', 61 61 'Programming Language :: Python', 62 'Framework :: MapFish',62 'Framework :: Pylons', 63 63 'Topic :: Scientific/Engineering :: GIS', 64 64 'Topic :: Internet :: WWW/HTTP', 65 65 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 66 66 'Topic :: Internet :: WWW/HTTP :: WSGI', 67 'Topic :: Internet ::Software Development :: Libraries :: Python Modules',67 'Topic :: Software Development :: Libraries :: Python Modules', 68 68 ], 69 69 entry_points = """ … … 75 75 mf-layer = mapfish.commands:MapFishLayerCommand 76 76 """, 77 long_description = """78 MapFish79 =======77 long_description = """ 78 MapFish 79 ======= 80 80 81 MapFish is a Pylons-based web framework with GIS orientations.81 MapFish is a Pylons-based web framework with GIS orientations. 82 82 83 MapFish provides:83 MapFish provides: 84 84 85 85 * a geometry type which is to be used when mapping PostGIS tables 86 with SQLAlchemy86 with SQLAlchemy 87 87 88 88 * a paster command to generate model and controller mode 89 corresponding to layers (PostGIS tables) defined in a configuration90 file89 corresponding to layers (PostGIS tables) defined in a 90 configuration file 91 91 92 92 * an implementation of a RESTful protocols for creating, reading, 93 updating, and deleting geographic objects (features)93 updating, and deleting geographic objects (features) 94 94 95 MapFish relies on the geojson and shapely packages, see96 http://gispython.org.95 MapFish relies on the geojson and shapely packages, see 96 http://gispython.org. 97 97 98 MapFish projects are Pylons projects, the project developer99 therefore fully benefits from the power of Pylons and its100 companion components (SQLAlchemy, Mako, etc.).98 MapFish projects are Pylons projects, the project developer 99 therefore fully benefits from the power of Pylons and its 100 companion components (SQLAlchemy, Mako, etc.). 101 101 102 Current status103 --------------102 Current status 103 -------------- 104 104 105 MapFish 1.2described in this page is the current stable version.105 MapFish 1.3dev described in this page is the current stable version. 106 106 107 Download and Installation108 -------------------------107 Download and Installation 108 ------------------------- 109 109 110 MapFish can be installed with `Easy Install111 <http://peak.telecommunity.com/DevCenter/EasyInstall>`_ by typing::110 MapFish can be installed with `Easy Install 111 <http://peak.telecommunity.com/DevCenter/EasyInstall>`_ by typing:: 112 112 113 > easy_install mapfish114 """113 > easy_install mapfish 114 """ 115 115 )
