Changeset 3388

Show
Ignore:
Timestamp:
03/02/10 10:26:18 (2 years ago)
Author:
elemoine
Message:

apply patches from
https://trac.mapfish.org/trac/mapfish/ticket/550
https://trac.mapfish.org/trac/mapfish/ticket/553
https://trac.mapfish.org/trac/mapfish/ticket/550
https://trac.mapfish.org/trac/mapfish/ticket/560

Location:
framework/server/branches/1.2
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • framework/server/branches/1.2/mapfish/commands.py

    r3083 r3388  
    110110        """Main command to create a mapfish controller""" 
    111111        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  
    119112            # read layers.ini 
    120113            config = ConfigParser() 
    121114            config.read(['layers.ini']) 
    122115            # 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): 
    124118                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) 
    126121 
    127122            # 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') 
    131136 
    132137            # check the name isn't the same as the package 
    133138            basePkg = fileOp.find_dir('controllers', True)[0] 
    134             if basePkg.lower() == name.lower(): 
     139            if basePkg.lower() == pluralName.lower(): 
    135140                raise BadCommand( 
    136141                    'Your controller name should not be the same as ' 
     
    138143 
    139144            # validate the name 
    140             name = name.replace('-', '_') 
     145            name = pluralName.replace('-', '_') 
    141146            validateName(name) 
    142147 
    143148            # set test file name 
    144             fullName = os.path.join(directory, name) 
     149            fullName = os.path.join(pluralDirectory, name) 
    145150            if not fullName.startswith(os.sep): 
    146151                fullName = os.sep + fullName 
     
    149154            # set template vars 
    150155            modName = name 
    151             fullModName = os.path.join(directory, name) 
     156            fullModName = os.path.join(pluralDirectory, name) 
    152157            contrClass = util.class_name_from_module_name(name) 
    153158            modelClass = util.class_name_from_module_name(singularName) 
    154             modelTabObj = name + '_table' 
    155159 
    156160            # setup the controller 
     
    162166                 'contrClass': contrClass, 
    163167                 'modelClass': modelClass, 
    164                  'modelTabObj': modelTabObj, 
    165                  'basePkg': basePkg, 
    166                  'epsg': epsg}) 
     168                 'basePkg': basePkg}) 
    167169            fileOp.copy_file(template='controller.py_tmpl', 
    168                          dest=os.path.join('controllers', directory), 
     170                         dest=os.path.join('controllers', pluralDirectory), 
    169171                         filename=name, 
    170172                         template_renderer=paste_script_template_renderer) 
     
    179181            resource_command += ("config/routing.py file in the CUSTOM ROUTES section " 
    180182                                 "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) 
    184185 
    185186            print resource_command 
     
    223224        """Main command to create mapfish model""" 
    224225        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  
    232226            # read layers.ini 
    233227            config = ConfigParser() 
    234228            config.read(['layers.ini']) 
    235229            # 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): 
    237232                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) 
    239235 
    240236            # 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') 
    247244            else: 
    248245                schema = None 
    249246 
     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 
    250257            # 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(): 
    253260                raise BadCommand( 
    254                     'Your controller name should not be the same as ' 
     261                    'Your model name should not be the same as ' 
    255262                    'the package name %s' % basePkg) 
    256263 
    257264            # validate the name 
    258             name = name.replace('-', '_') 
     265            name = pluralName.replace('-', '_') 
    259266            validateName(name) 
    260267 
     
    273280                 'schema': schema}) 
    274281            fileOp.copy_file(template='model.py_tmpl', 
    275                          dest=os.path.join('model', directory), 
     282                         dest=os.path.join('model', pluralDirectory), 
    276283                         filename=name, 
    277284                         template_renderer=paste_script_template_renderer) 
  • framework/server/branches/1.2/mapfish/controllers/printer.py

    r3083 r3388  
    2828import simplejson 
    2929 
    30 from routes import url_for 
    3130from pylons.controllers import WSGIController 
    32 from pylons import config, request, response, session 
     31from pylons import config, request, response, session, url 
    3332from pylons.controllers.util import forward 
    3433 
     
    7473        if ret == 0: 
    7574            response.status = 200 
    76             response.headers['Content-Type'] = 'application/json; charset=utf-8' 
    7775            result = self._addURLs(result) 
    7876            if request.params.has_key('var'): 
     77                response.headers['Content-Type'] = 'text/javascript; charset=utf-8' 
    7978                return 'var ' + request.params['var'].encode('utf8') + '=' + result + ';' 
    8079            else: 
     80                response.headers['Content-Type'] = 'application/json; charset=utf-8' 
    8181                return result 
    8282        else: 
     
    206206        actions of this controller. 
    207207        """ 
    208         actionUrl = url_for(action = actionName, id = id) 
     208        actionUrl = url(controller="printer", action=actionName, id=id) 
    209209        if request.params.has_key('url'): 
    210210            fullUrl = request.params['url'].encode('utf8') 
    211             myUrl = url_for(action = fromAction) 
     211            myUrl = url(controller="printer", action=fromAction) 
    212212            if fullUrl == myUrl[1:]:  # support for very short relative URLs 
    213213                return actionUrl[1:] 
  • framework/server/branches/1.2/mapfish/lib/protocol.py

    r3083 r3388  
    349349            if obj is None: 
    350350                obj = self.mapped_class() 
    351                 obj.geometry = asShape(feature.geometry) 
    352351                create = True 
     352            obj.geometry = asShape(feature.geometry) 
    353353            for key in feature.properties: 
    354354                obj[key] = feature.properties[key] 
  • framework/server/branches/1.2/setup.py

    r3103 r3388  
    4343 
    4444setup(name                 = 'mapfish', 
    45       version              = '1.2', 
     45      version              = '1.2.1', 
    4646      license              = 'LGPLv3', 
    4747      install_requires     = requirements, 
     
    5454      description          = 'The MapFish web-mapping framework.', 
    5555      classifiers          = [ 
    56         'Development Status :: 3 - Alpha', 
     56        'Development Status :: 4 - Beta', 
    5757        'Intended Audience :: Developers', 
    5858        'Intended Audience :: Science/Research', 
     
    6060        'Operating System :: OS Independent', 
    6161        'Programming Language :: Python', 
    62         'Framework :: MapFish', 
     62        'Framework :: Pylons', 
    6363        'Topic :: Scientific/Engineering :: GIS', 
    6464        'Topic :: Internet :: WWW/HTTP', 
    6565        'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 
    6666        'Topic :: Internet :: WWW/HTTP :: WSGI', 
    67         'Topic :: Internet :: Software Development :: Libraries :: Python Modules', 
     67        'Topic :: Software Development :: Libraries :: Python Modules', 
    6868        ], 
    6969      entry_points         = """ 
     
    7575        mf-layer = mapfish.commands:MapFishLayerCommand 
    7676        """, 
    77       long_description           = """ 
    78         MapFish 
    79         ======= 
     77      long_description      = """ 
     78      MapFish 
     79      ======= 
    8080 
    81         MapFish is a Pylons-based web framework with GIS orientations. 
     81      MapFish is a Pylons-based web framework with GIS orientations. 
    8282 
    83         MapFish provides: 
     83      MapFish provides: 
    8484 
    8585        * a geometry type which is to be used when mapping PostGIS tables 
    86         with SQLAlchemy 
     86          with SQLAlchemy 
    8787 
    8888        * a paster command to generate model and controller mode 
    89         corresponding to layers (PostGIS tables) defined in a configuration 
    90         file 
     89          corresponding to layers (PostGIS tables) defined in a  
     90          configuration file 
    9191 
    9292        * an implementation of a RESTful protocols for creating, reading, 
    93         updating, and deleting geographic objects (features) 
     93          updating, and deleting geographic objects (features) 
    9494 
    95         MapFish relies on the geojson and shapely packages, see 
    96         http://gispython.org. 
     95      MapFish relies on the geojson and shapely packages, see 
     96      http://gispython.org. 
    9797 
    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.). 
     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.). 
    101101 
    102         Current status 
    103         -------------- 
     102      Current status 
     103      -------------- 
    104104 
    105         MapFish 1.2 described in this page is the current stable version. 
     105      MapFish 1.3dev described in this page is the current stable version. 
    106106 
    107         Download and Installation 
    108         ------------------------- 
     107      Download and Installation 
     108      ------------------------- 
    109109 
    110         MapFish can be installed with `Easy Install 
    111         <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:: 
    112112 
    113             > easy_install mapfish 
    114         """ 
     113          > easy_install mapfish 
     114      """ 
    115115)