4D v16.3

Project method properties

Home

 
4D v16.3
Project method properties

Project method properties  


 

 

After creating a project method, you can rename it and modify its properties. Project method properties mainly concern their access and security conditions (access by users, integrated servers or services) as well as their execution mode. 

The other types of methods do not have specific properties. Their properties are related to those of the objects to which they are attached.

To modify the properties of a project method:

  1. In the Method editor, select the Method Properties... command in the Method menu.
    OR
    On the Methods Page of the Explorer, right-click on the project method and select Method Properties... in the context menu or options menu.
    The Method Properties dialog box appears.

Note: A batch setting function can be used to modify a property for all or part of the database project methods in a single operation (see Batch setting for method attributes).

Name  

You can change the name of a project method in the "Name" area of the Method properties window or in the Explorer.

The new name must comply with 4D naming rules (see Identifiers in the 4D Language Reference manual). If a method with the same name already exists, 4D displays a message saying that the method name has already been used. If necessary, 4D resorts the list of methods again. 

Warning: Changing the name of a method already used in the database can invalidate any methods or formulas that use the old method name and runs the risk of disrupting application functioning. You can rename the method manually but it is strongly recommended to use the renaming function for project methods, described in Renaming. With this function, you can automatically update the name wherever the method is called throughout the Design environment.

With 4D Server, the method name is changed on the server when you finish editing it. If more than one user is modifying the method name at the same time, the final method name will be the name specified by the last user to finish editing it. You may want to specify a method owner so that only certain users can change the method’s name

Note: Database methods cannot be renamed. The same goes for triggers, form methods, and object methods, which are bound to objects and take their names from the object concerned. 

You can control how project methods are used and/or called in different contexts using attributes. Note that you can set attributes for an entire selection of project methods using the Explorer (see following section).

If you do not want users to be able to run a project method using the Method... command of the Run menu, you can make it Invisible by checking this option. An invisible method does not appear in the method execution dialog box (see From the Execute Method dialog box). 

When you make a project method invisible, it is still available to database programmers. It remains listed on the Current form table of the Explorer and in the list of routines in the Method editor.

This attribute is used within the framework of components. When it is checked, it indicates that the method will be available to components when the application is used as the host database. On the other hand, when the application is used as a component, the method will be available to the host databases. 

For more information about components, refer to the Developing and installing 4D components chapter.

This attribute is only taken into account for a 4D application in client/server mode. When this option is checked, the project method is always executed on the server, regardless of how it is called. 

For more information about this option, refer to Execute on Server attribute in the 4D Server Reference Manual.

This option allows you to declare the method eligible for execution in preemptive mode. By default, 4D executes all the project methods of your applications in cooperative mode.  If you want to benefit from the preemptive mode feature, you must explicitly declare all the methods that you want to be started in preemptive mode. The compiler will then check that these methods are actually thread-safe.

Note: Execution in preemptive mode is only available in 64-bit versions of 4D in compiled mode. For more information, refer to the Preemptive 4D processes section.

 

The following options are provided:

  • Can be run in preemptive processes: By checking this option, you declare that the method is capable of being run in a preemptive process and therefore should be run in preemptive mode whenever possible. The "preemptive" property of the method is set to "capable".
    When this option is checked, the 4D compiler will verify that the method is actually capable and will return errors if this is not the case -- for example, if it directly or indirectly calls commands or methods that cannot be run in preemptive mode (the entire call chain is parsed but errors are only reported to the first sublevel). You can then edit the method so that it becomes thread-safe, or select another option.
    If the method's preemptive capability is approved, it is tagged "thread-safe" internally and will be executed in preemptive mode whenever the required conditions are met. This property defines its eligibility for preemptive mode but does not guarantee that the method will actually be run in preemptive mode, since this execution mode requires a specific context (see When is a process started preemptively?).
  • Cannot be run in preemptive processes: By checking this option, you declare that the method must never be run in preemptive mode, and therefore must always be run in cooperative mode, as in previous 4D versions. The "preemptive" property of the method is set to "incapable".
    When this option is checked, the 4D compiler will not verify the ability of the method to run preemptively; it is automatically tagged "thread-unsafe" internally (even if it is theoretically capable). When called at runtime, this method will "contaminate" any other methods in the same thread, thus forcing this thread to be executed in cooperative mode, even if the other methods are thread-safe.
  • Indifferent (default): By checking this option, you declare that you do not want to handle the preemptive property for the method. The "preemptive" property of the method is set to "indifferent".
    When this option is checked, the 4D compiler will evaluate the preemptive capability of the method and will tag it internally as "thread-safe" or "thread-unsafe". No error related to preemptive execution is returned. If the method is evaluated as thread-safe, at runtime it will not prevent preemptive thread execution when called in a preemptive context. Conversely, if the method is evaluated "thread-unsafe", at runtime it will prevent any preemptive thread execution when called.
    Note that with this option, whatever the internal thread safety evaluation, the method will always be executed in cooperative mode when called directly by 4D as the first parent method (for example through the New process command). If tagged "thread-safe" internally, it is only taken into account when called from other methods inside a call chain.

Availability attributes specify the external services which are allowed to explicitly call the method.

This attribute lets you publish the current method as a Web Service accessible via SOAP requests. For more information, refer to the Publication and use of Web Services chapter. When this option is checked, the Published in WSDL option is enabled.

In the Explorer, project methods that are offered as a Web Service are given a specific icon .

Note: You cannot publish a method as a Web service if its name includes characters that do not comply with XML nomenclature (e.g. containing spaces). If the method name is not in keeping with this, 4D does not assign the property.

This attribute is only available when the "Web Service" attribute is checked. It lets you include the current method in the WSDL of the 4D application. For more information about this, refer to Generation of the WSDL

In the Explorer, project methods that are offered as a Web Service and published in WSDL are given a specific icon

This option is used to reinforce 4D Web server security: when it is not checked, the project method cannot be executed via an HTTP request containing the special 4DACTION URL used for calling 4D methods (as well as the former 4DMETHOD URL), nor the special 4DSCRIPT, 4DTEXT and 4DHTML tags (as well as the former 4DVAR and 4DHTMLVAR tags). For more information, refer to URLs and Form Actions and 4D HTML Tags in the 4D Language Reference manual.

In the Explorer, project methods with this attribute are given a specific icon .

For security reasons, this option is unchecked by default. Each method that can be executed using the special Web URL or tags must be indicated individually.

SQL  

When it is checked, this option allows the project method to be executed by the SQL engine of 4D. By default, it is not selected, which means that, unless explicitly authorized, 4D project methods are protected and cannot be called by the SQL engine of 4D. 

This property applies to all internal and external SQL queries — executed via the ODBC driver, SQL code inserted between the Begin SQL/End SQL  tags or the QUERY BY SQL command.

Notes:

  • Even if a method has the “SQL” attribute, access rights set at the level of the database settings and method properties are taken into account for the execution of the method.
  • The ODBC SQLProcedure function only returns project methods with the “SQL” attribute.

For more information, refer to 4D SQL engine implementation in the 4D SQL manual.

This option configures the availability and scope of action for the method as part of a 4D Mobile link with a Wakanda server.

For more information about this option, refer to Configuring the 4D Database in the 4D Mobile manual.

You can control access to methods by setting Access and Owner privileges for groups of users. For information about creating a password access system with users and groups, refer to the Users and groups chapter.

  • The "Access group" drop-down list controls which group can execute the method. If a user that is not in this group attempts to execute the method, 4D displays a message saying that the user’s password does not allow them to execute the method.
  • The "Owner group" drop-down list controls which group can edit the method in the Design environment. If a user who is not in this group attempts to edit the method in the Design environment, 4D displays a message saying that the user does not have the access privilege to edit the method.

Users who are assigned to both groups can use or modify the method without restriction.

Using the "Attributes for methods" dialog box, you can modify an attribute (Invisible, Offered as a Web Service, etc.) for all or part of the database project methods in a single operation. This feature is especially useful for modifying the attributes of a large number of project methods. It can also be used during development to apply common attributes to groups of similar methods quickly.

For batch setting of method attributes:

  1. On the Methods Page of the 4D Explorer, expand the options menu, then choose the Batch setting of attributes... command.

    The “Attributes for methods” dialog box appears:
  2. In the “Matching method name:” area, enter a string that lets you designate the methods you want to modify as a batch.
    The character string is used as a search criterion for the method names.
    Use the wildcard character @ to help define groups of methods:
    • To designate methods whose names begin with..., type @ at the end of the string. For example: web@
    • To designate methods whose names contain..., type @ in the middle of the string. For example: web@write
    • To designate methods whose names end with..., type @ at the beginning of the string. For example: @write
    • To designate all of the methods, just type @ in the area.
      Notes:
      • The search does not take upper/lower case into account.
      • You can enter several @ characters in the string, for example dtro_@web@pro.@
  3. In the “Attribute to Modify” area, choose an attribute from the drop-down list, then click on the True or False radio button corresponding to the value to be applied.
    Note: If the “Published in WSDL” attribute is set to True, it will only be applied to project methods already containing the “Offered as a Web Service” attribute.
  4. Click on Apply.
    The modification is applied instantly to all the project methods designated by the character string entered.

 
PROPERTIES 

Product: 4D
Theme: Editing methods

 
HISTORY 

Modified: 4D v15 R5

 
ARTICLE USAGE

4D Design Reference ( 4D v16)
4D Design Reference ( 4D v16.1)
4D Design Reference ( 4D v16.3)