Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Commit 818c642

Browse files
committed
tweaking scaffold and docs
1 parent cce9836 commit 818c642

File tree

9 files changed

+75
-49
lines changed

9 files changed

+75
-49
lines changed

docs/source/changelog.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Changelog
22
=========
33

44
* :release:`0.3.1 <2015-07-06>`
5-
* :support:`- backported` Added support for callables in "default" field argument
6-
* :support:`- backported` Added support for "onupdate" field argument
5+
* :support:`- backported` Added support for callables in 'default' field argument
6+
* :support:`- backported` Added support for 'onupdate' field argument
77

88
* :release:`0.3.0 <2015-06-14>`
99
* :support:`-` Added python3 support
@@ -21,7 +21,7 @@ Changelog
2121
* :bug:`-` Fixed custom processors
2222

2323
* :release:`0.2.0 <2015-05-18>`
24-
* :feature:`-` Added support for securitySchemes, authentication (Pyramid "auth ticket") and ACLs
24+
* :feature:`-` Added support for securitySchemes, authentication (Pyramid 'auth ticket') and ACLs
2525
* :support:`-` Added several display options to schemas
2626
* :support:`-` Added unit tests
2727
* :support:`-` Improved docs

docs/source/fields.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Available Types
2626
* list
2727
* dict
2828

29+
2930
Required Fields
3031
---------------
3132

@@ -38,6 +39,7 @@ You can set a field as required by setting the ``required`` property.
3839
(...)
3940
}
4041
42+
4143
Primary Key
4244
-----------
4345

@@ -52,6 +54,7 @@ You can set a field as the primary key by setting the ``primary_key`` property u
5254
}
5355
}
5456
57+
5558
Constraints
5659
-----------
5760

@@ -68,28 +71,24 @@ You can set a minimum and/or maximum length of your field by setting the ``min_l
6871
}
6972
}
7073
71-
Custom Field Processors
72-
-----------------------
7374
74-
You can set custom field processors by referencing the names of such processors in the ``processors`` property under ``args``.
75+
Field Processors
76+
----------------
77+
78+
You can define field processors by referencing their names in the ``before_validation`` and ``after_validation`` properties under ``args``. `before_` and `after_` prefixes refer when those processors are executed, either before or after database validation.
7579

7680
.. code-block:: json
7781
7882
"field": {
7983
(...)
8084
"args": {
81-
"processors": ["custom_processor"]
85+
"before_validation": ["custom_processor"],
86+
"after_validation": ["other_custom_processor"]
8287
}
8388
}
8489
85-
You can then define each custom processor in a function in your ``__init__.py`` file.
90+
You can read more about field processors :doc:`here <processors>`.
8691

87-
.. code-block:: python
88-
89-
@registry.add
90-
def custom_processor(value):
91-
""" This is a field processor """
92-
return (value or '').lower().strip()
9392

9493
Relationship Fields
9594
-------------------
@@ -107,6 +106,7 @@ For relationship fields, you can define the name of your 'relation' model by set
107106
}
108107
}
109108
109+
110110
Default Value
111111
-------------
112112

@@ -132,6 +132,7 @@ The ``default`` value can also be set to a Python callable, e.g.
132132
}
133133
},
134134
135+
135136
Update Default Value
136137
--------------------
137138

@@ -146,6 +147,7 @@ You can set an update default value for your field by setting the ``onupdate`` p
146147
}
147148
},
148149
150+
149151
List Fields
150152
-----------
151153

docs/source/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Ramses
22
======
33

4-
Github: `<http://github.com/brandicted/ramses>`_
4+
Source code: `<http://github.com/brandicted/ramses>`_
55

6-
Ramses is a library that generates a RESTful API using RAML. It uses Pyramid and `Nefertari <https://nefertari.readthedocs.org/>`_ which provides ElasticSearch-powered views.
6+
Ramses is a library that generates a RESTful API using RAML. It uses Pyramid and `Nefertari <https://nefertari.readthedocs.org/>`_ which provides `ElasticSearch-powered requests <http://nefertari.readthedocs.org/en/stable/making_requests.html>`_.
77

88
Table of Contents
99
=================
@@ -15,6 +15,7 @@ Table of Contents
1515
raml
1616
schemas
1717
fields
18+
processors
1819
changelog
1920

2021
.. image:: ramses.jpg

docs/source/processors.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Field Processors
2+
================
3+
4+
Writing Processors
5+
------------------
6+
7+
You can then define each custom processor in a function in your ``__init__.py`` file. A processor receives two arguments: `instance`, the object's instance, and `new_value`, the new value being set.
8+
9+
.. code-block:: python
10+
11+
@registry.add
12+
def custom_processor(instance, new_value):
13+
""" This is a field processor """
14+
return (new_value or '').lower().strip()
15+
16+
17+
Accessing Other Models
18+
----------------------
19+

ramses/scaffolds/ramses_starter/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Installation
22
```
33
$ pip install -r requirements.txt
4+
```
45

56
## Run
67
```

ramses/scaffolds/ramses_starter/local.ini_tmpl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[app:{{package}}]
22
use = egg:{{package}}
3+
4+
# Ramses
35
ramses.raml_schema = api.raml
6+
ramses.auth = false
47

8+
# Nefertari
59
nefertari.engine = nefertari_{{engine}}
6-
7-
ramses.auth = false
810
auth_tkt_secret = {{random_string}}
911
debug = true
1012
public_max_limit = 100
11-
1213
system.user = system
1314
system.password = 123456
1415
system.email = user@domain.com
@@ -27,18 +28,18 @@ elasticsearch.sniff = false
2728
elasticsearch.index_name = {{package}}
2829
elasticsearch.index.disable = false
2930
elasticsearch.enable_refresh_query = false
31+
elasticsearch.enable_aggregations = false
32+
elasticsearch.enable_polymorphic_query = false
3033

3134
# {{package}}
3235
host = localhost
33-
base_url = http://%(host)s
36+
base_url = http://%(host)s:6543
3437

3538
# CORS
3639
cors.enable = false
3740
cors.allow_origins = %(base_url)s
3841
cors.allow_credentials = true
3942

40-
request_timing.enable = true
41-
4243
[composite:main]
4344
use = egg:Paste#urlmap
4445
/api/ = {{package}}
@@ -68,12 +69,12 @@ handlers =
6869
qualname = {{package}}
6970

7071
[logger_nefertari]
71-
level = DEBUG
72+
level = INFO
7273
handlers =
7374
qualname = nefertari
7475

7576
[logger_ramses]
76-
level = DEBUG
77+
level = INFO
7778
handlers =
7879
qualname = ramses
7980

ramses/scaffolds/ramses_starter/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
nefertari
22
ramses
3+
34
Paste==2.0.2
45
pyramid==1.5.7
56
waitress==0.8.9

ramses/scaffolds/ramses_starter/setup.py_tmpl

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@ from setuptools import setup, find_packages
33
requires = ['pyramid']
44

55
setup(name='{{package}}',
6-
version='0.0.1',
7-
description='',
8-
long_description='',
9-
classifiers=[
10-
"Programming Language :: Python",
11-
"Framework :: Pyramid",
12-
"Topic :: Internet :: WWW/HTTP",
13-
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
14-
],
15-
author='',
16-
author_email='',
17-
url='',
18-
keywords='web pyramid pylons',
19-
packages=find_packages(),
20-
include_package_data=True,
21-
zip_safe=False,
22-
install_requires=requires,
23-
tests_require=requires,
24-
test_suite="{{package}}",
25-
entry_points="""\
26-
[paste.app_factory]
27-
main = {{package}}:main
28-
""")
6+
version='0.0.1',
7+
description='',
8+
long_description='',
9+
classifiers=[
10+
"Programming Language :: Python",
11+
"Framework :: Pyramid",
12+
"Topic :: Internet :: WWW/HTTP",
13+
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
14+
],
15+
author='',
16+
author_email='',
17+
url='',
18+
keywords='web pyramid pylons raml ramses',
19+
packages=find_packages(),
20+
include_package_data=True,
21+
zip_safe=False,
22+
install_requires=requires,
23+
tests_require=requires,
24+
test_suite="{{package}}",
25+
entry_points="""\
26+
[paste.app_factory]
27+
main = {{package}}:main
28+
""",
29+
)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
author='Brandicted',
3333
author_email='hello@brandicted.com',
3434
url='https://github.com/brandicted/ramses',
35-
keywords='web pyramid pylons',
35+
keywords='web pyramid pylons nefertari raml',
3636
packages=find_packages(),
3737
include_package_data=True,
3838
zip_safe=False,
@@ -41,5 +41,5 @@
4141
test_suite="ramses",
4242
entry_points="""\
4343
[pyramid.scaffold]
44-
ramses_starter=ramses.scaffolds:RamsesStarterTemplate
44+
ramses_starter = ramses.scaffolds:RamsesStarterTemplate
4545
""")

0 commit comments

Comments
 (0)