Giter Site home page Giter Site logo

pylons / pyramid-cookiecutter-starter Goto Github PK

View Code? Open in Web Editor NEW
93.0 15.0 49.0 220 KB

A Cookiecutter (project template) for creating a Pyramid starter project with choices for template language (Jinja2, Chameleon, or Mako), persistent backend (none, SQLAlchemy with SQLite, or ZODB), and mapping of URLs to routes (URL dispatch or traversal)

Python 77.24% CSS 6.13% Mako 8.58% Jinja 8.05%
cookiecutter-template pyramid jinja2 chameleon mako sqlalchemy sqlite zodb traversal url-dispatch

pyramid-cookiecutter-starter's Introduction

pyramid-cookiecutter-starter

Latest Branch Status

A Cookiecutter (project template) for creating a Pyramid starter project.

Customizable options upon install include choice of:

  • template language (Jinja2, Chameleon, or Mako)
  • persistent backend (none, SQLAlchemy with SQLite, or ZODB)
  • mapping of URLs to routes (if the selected persistent backend is "none" or "sqlalchemy" then URL dispatch, or if "zodb" then traversal)

Requirements

Versions

This cookiecutter has several branches to support new features in Pyramid or avoid incompatibilities.

  • latest aligns with the latest stable release of Pyramid, and is the default branch on GitHub.
  • main aligns with the main branch of Pyramid, and is where development takes place.
  • x.y-branch aligns with the x.y-branch branch of Pyramid.

Usage

  1. Generate a Pyramid project, following the prompts from the command.

    $ cookiecutter gh:Pylons/pyramid-cookiecutter-starter

    Optionally append a specific branch checkout to the command:

    $ cookiecutter gh:Pylons/pyramid-cookiecutter-starter --checkout main
  2. Create a virtual environment, upgrade packaging tools, and install your new project and its dependencies. These steps are output to the console and are written to the file in <my_project>/README.txt by the cookiecutter, and are slightly different for Windows.

    # Change directory into your newly created project if not already there. Your
    # current directory should be the same as this README.txt file and setup.py.
    $ cd <my_project>
    # Create a Python virtual environment, if not already created.
    $ python3 -m venv env
    # Upgrade packaging tools.
    $ env/bin/pip install --upgrade pip setuptools
    # Install the project in editable mode with its testing requirements.
    $ env/bin/pip install -e ".[testing]"
    # The previous step installs the latest stable release of Pyramid.
    # Optionally install a specific version of Pyramid.
    # For example, the unreleased version of the main branch:
    env/bin/pip install -e git+https://github.com/pylons/pyramid.git@main#egg=pyramid
  3. If you selected sqlalchemy as a backend, there will be additional steps in the output and README.txt.
  4. Run your project's tests.

    $ env/bin/pytest
  5. Run your project.

    $ env/bin/pserve development.ini

pyramid-cookiecutter-starter's People

Contributors

cguardia avatar dependabot[bot] avatar digitalresistor avatar drnextgis avatar ergo avatar fangpenlin avatar goodwillcoding avatar justgerard avatar jvanasco avatar krysros avatar luhn avatar mcdonc avatar mikeckennedy avatar mmerickel avatar natim avatar petrblahos avatar silenius avatar stevepiercy avatar stloma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyramid-cookiecutter-starter's Issues

cookie cutter not found

Ok so I followed the instructions and tried

  1. cloning the repo - nogo
  2. copying the repo - wont run
  3. copying a tutorial - no go

what format or function runs the code?
The instructions in your code seem to supposed additional code that needs to be on the terminal yet you forget that some of us are brand new and only follow instructions.

cookiecutter gh:Pylons/pyramid-cookiecutter-starter
bash: cookiecutter: command not found

cookiecutter https://github.com/Pylons/pyramid-cookiecutter-starter
-bash: cookiecutter: command not found

Please complete your tutorial as it doesn't run as noted, i'm eager to run a pyramid server as my instructor says it works but your code generates those errors when I try to run it.

No module named dateutil.rrule

Hello there!

I was trying to use cookicutter today and got this:

You've downloaded /home/rre/.cookiecutters/pyramid-cookiecutter-starter before. Is it okay to delete and re-download it? [yes]: yes
Unable to load extension: No module named 'dateutil.rrule'

dateutil was installed globally. Also cookiecutter was installed globally, then uninstalled and installed with the --user flag as stated in Pyramid's docs and it ends up in the same.

If I try to import dateutil.rrule from a Python CLI it throws the same error, but I couldn't find anything about this module being deprecated or something.

This happend under Manjaro Linux (Arch based) and Python 3.8.

Any help would be much appreciated. Thanks a lot.

README.txt instructions to cd into project needs clarification

In PyCharm, if you create a new Pyramid project, the README.txt says:

- Change directory into your newly created project.

    cd <PROJECT_NAME>

However PyCharm automatically cd's into the newly created project directory, so this step is not necessary.

The fix is to update the language for PyCharm users.

Add structure to templates folder

I would like to move layout.py / layout.jinja2 to a folder called shared and rename them to _layout.* to indicate they are never meant to be the top-level template. Thoughts?

Supporting YAML configuration with cookiecutter

Hi,

I'd like to have cookiecutter support for YAML configuration files. This would use plaster-yaml.

Would you accept a patch that asks whether to use YAML, JSON, or PasteDeploy .ini config files?
This would have to be based on the "main" branch. Besides main being the development branch, it is the only branch which packages with a pyproject.toml file.

Alternately, I can fork the pyramid-cookiecutter-starter.

Dependencies pyramid-jinja2 have a hyphen in pypi

The scaffold lists some dependencies in setup.py with an underscore for example pyramid_jinja2 because that is what the project is called. However in pypi it's actually stored as pyramid-jinja2 with a hyphen.

This constantly triggers PyCharm saying "pyramid_jinja2 is not installed" so it could also be seen as a PyCharm bug, because pyramid-jinja2 with a hyphen is installed.

But it's easy enough to fix it in the project template by using the package name exactly as it is listed in pypi.

https://pypi.org/project/pyramid-jinja2/

__init__.py could use more guidance on structure

I would like to organize __init__.py's main:

def main(...):
   init_includes()
   init_routing()
   # making room for more things like init_logging(), init_db(), etc
   return run...

What do you think? As written it's kind of without guidance.

name of scaffolds

Just to raise the possible issue before everything is done and updated everywhere... since it's done using cookie cutter would it make more sense to name those scaffolds like something-cookie ?

  • pyramid-starter-cookie
  • pyramid-alchemy-cookie
  • pyramid-zodb-cookie

Bower or NPM for static resources?

We currently link to CDN files for jquery, respondjs, bootstrap, etc. This is annoying because if you want to work with these projects without internet access you're kinda stuck. Think coffee shop with poor wifi, or on a train/plane, etc.

I propose we use either NPM or Bower to install these into the static folder. This means users can bower upgrade or npm upgrade as they want but aren't dependent upon network access.

Thoughts? I'll do this if you're keen.

Test coverage for ZODB backend is below 100%

After generating a project using ZODB on the backend, then running tests with coverage via pytest --cov reveals test coverage is only at 42%.

Name                           Stmts   Miss  Cover
--------------------------------------------------
zodb_demo/__init__.py             16     11    31%
zodb_demo/models/__init__.py       8      4    50%
zodb_demo/pshell.py                6      6     0%
zodb_demo/routes.py                2      2     0%
zodb_demo/views/__init__.py        0      0   100%
zodb_demo/views/default.py         4      0   100%
zodb_demo/views/notfound.py        4      0   100%
--------------------------------------------------
TOTAL                             40     23    42%

See also #79.

pcreate -s starter app_name is not chameleon

I understand that pcreate is a deprecated operation. However, pcreate -s starter [app] is not backwards compatible.

If you type pcreate -l you get:

Available scaffolds:
  alchemy:                 Pyramid project using SQLAlchemy, SQLite, URL dispatch, and Jinja2
  pyramid_jinja2_starter:  Pyramid Jinja2 starter project
  starter:                 Pyramid starter project using URL dispatch and Chameleon
  zodb:                    Pyramid project using ZODB, traversal, and Chameleon

Yet running pcreate -s starter [app] generates a jinja2 based app even though the listing has been and continues to be chameleon.

Using `setUp`/`tearDown` methods from `pyramid.testing` in `conftest.py`?

Please, help me to understand.

Wouldn't it be more correct to use methods setUp/tearDown (from pyramid.testing) during the initializing of the test app fixtures?

Considering the following part of docstring for method setUp:

If you use the get_current_* functions (or call Pyramid code
that uses these functions) without calling setUp,
pyramid.threadlocal.get_current_registry will return a global
application registry, which may cause unit tests to not be
isolated with respect to registrations they perform.

Can we have a random port?

Currently, every project is set to run on 6543.

This is annoying if we want to run two projects at the same time. This could easily be fixed if we randomly choose a port between 6000-9999 each time we gen the project. I'll do this if you like the idea.

Test coverage of generated project dropped to 88%

When running tests with coverage for a project generated from the cookiecutter with backend of none, coverage is at 88%, missing two statements in notfound.py.

PR coming soon to bump it back up to 100%.

Cookiecutter for mako templates

Seeing there is a choice of chameleon and jinja2 templates, I am wondering if we
should be adding an option to choose mako templates?

Cannot create new project!

Hi guys,

I don't know how the system worked its way into this state, but it seems you cannot create a new project, and run it, from this template.

Try these steps:

  1. mkdir web_proj
  2. cd web_proj
  3. python3 -m venv --copies .env
  4. . ./.env/bin/activate
  5. pip install cookiecutter
  6. cookiecutter https://github.com/Pylons/pyramid-cookiecutter-starter branch=1.9-branch (branch is optional, also fails on latest)
  7. Choose defaults (2 for template)
  8. cd pyramid_scaffold
  9. python setup.py develop
  10. pserve development.ini

Error:

... 
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 394, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 444, in _interpolate_some
    "found: %r" % (rest,))
configparser.InterpolationSyntaxError: Error in file development.ini: '%' must be followed by '%' or '(', found: '%{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'

Any ideas what broke? Did I somehow do something wrong?

Thanks,
Michael

do not create a virtualenv

I've been thinking about this as I dive into getting things sorted for an official release. There are several issues with having the cookiecutter automatically create a virtualenv that I want on the record before we go forward.

First, the easy one.. the inconsistency that it doesn't work on Python 2.7. Not a big deal but definitely a con.

Second, the real issue to me is that the user no longer has control over which python is used for the scaffold. It's coupled to the python that cookiecutter is installed in, which can be hard to trace. For example, cookiecutter is installable from homebrew (brew install cookiecutter). This currently defaults to python2.7 and thus does not create a virtualenv.

On top of that the pre-hook says it will create a virtualenv (even when it won't - this obviously needs to be fixed either way). And, even when it does, the pre-hook doesn't pause to let the user know.. it's just a quick message that scrolls by so I'm not sure what the point of it is. Maybe it should at least ask the user if they want to create a virtualenv?

In general I do not think that having the cookiecutters create virtualenvs helps with the tutorial situation... in my opinion it probably makes them slightly harder to explain due to some of these things that can go wrong.

Finally, there's very few cookiecutters that I've seen that try to do this and so it's not really expected by anyone - and doing things that are unexpected is usually not a good sign.

What do other people think?

@bertjwregeer, @stevepiercy, @cguardia, @blaflamme

Branch according to Pyramid 1.8+ releases

At some point soon, we'll need to establish branches for each of the cookiecutters so that they align with Pyramid versions.

Ideally this would occur after merging all three cookiecutters into one. But if we release a Pyramid (1.9 or 2.0?) where a cookiecutter requires features that don't work on 1.8, then we must branch the cookiecutter to 1.8-branch, <future>-branch, and master.

Refs IRC:
https://botbot.me/freenode/pyramid/2017-03-13/?msg=82383937&page=2

Should the page really be in the request culture?

Hi guys,

Here come a few pieces of feedback. I'll do them across several issues so we can accept / reject them individually.

At the top of the HTML file in this template, you have

<html lang="{{ '{{request.locale_name}}' }}">

This has been here forever. But I question whether static HTML should really vary in the culture per request. Shouldn't this somehow be either just en-us flat or part of the template question?

If neither of these are OK, then let's just not add it. But the worst possible choice seems to vary by request when the content is static.

Thoughts?

Test coverage for sqlalchemy backend is below 100%

After generating a project using SQLAlchemy on the backend, then running tests with coverage via pytest --cov reveals test coverage is only at 55%.

Name                            Stmts   Miss  Cover
---------------------------------------------------
sqla/__init__.py                    8      6    25%
sqla/models/__init__.py            24      0   100%
sqla/models/meta.py                 5      0   100%
sqla/models/mymodel.py              8      0   100%
sqla/pshell.py                      7      7     0%
sqla/routes.py                      3      3     0%
sqla/scripts/__init__.py            0      0   100%
sqla/scripts/initialize_db.py      22     22     0%
sqla/views/__init__.py              0      0   100%
sqla/views/default.py              12      0   100%
sqla/views/notfound.py              4      4     0%
---------------------------------------------------
TOTAL                              93     42    55%

See also #80.

Add "css and js slots" to the template

We have a spot where each individual page can put its content. But sometimes we want to include either a JS file or CSS file for just one page / template.

I think we should have additional, optional sections to allow the page to punch in a CSS below the default css on the top or JS file at the bottom below the default JS.

Thoughts?

cookiecutter master branch installs pyramid==1.10.5

I caught this when running through the docs. I think that the master branch of the cookiecutter should install the master branch of pyramid. The only reason I noticed this was when I ran tests and the imp error that appears in Pyramid 1.10.5 resurfaced, and I know it was fixed on master for the pending 2.0. release.

However I cannot figure out how to do this in setup requires, and it appears that link options for VCS has been removed in pip 19.

https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#dependencies-that-aren-t-in-pypi

I can install Pyramid master manually:

$VENV/bin/pip install -e git+https://github.com/pylons/pyramid.git@master#egg=pyramid 

How should we handle this? I could cheat and change setup.py to use the 2.0b, but that's a bad pattern to follow when there is no beta or alpha release on PyPI.

pkg_resources.DistributionNotFound

pkg_resources.DistributionNotFound: The 'my_project' distribution was not found and is required by the application

whenever I start my project I keep on getting this error, I can't seem to fix it, I followed all the steps on the README.txt, not sure what's the problem.
I create my virtual environment like this: virtualenv -p python3 env

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.